@@ -43,7 +43,8 @@ use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection, Pro
4343use rustc_middle:: mir:: FakeReadCause ;
4444use rustc_middle:: traits:: ObligationCauseCode ;
4545use rustc_middle:: ty:: {
46- self , ClosureSizeProfileData , Ty , TyCtxt , TypeckResults , UpvarArgs , UpvarCapture ,
46+ self , ClosureSizeProfileData , Ty , TyCtxt , TypeVisitableExt as _, TypeckResults , UpvarArgs ,
47+ UpvarCapture ,
4748} ;
4849use rustc_session:: lint;
4950use rustc_span:: sym;
@@ -191,6 +192,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
191192 ) ;
192193 }
193194 } ;
195+ let args = self . resolve_vars_if_possible ( args) ;
194196 let closure_def_id = closure_def_id. expect_local ( ) ;
195197
196198 assert_eq ! ( self . tcx. hir( ) . body_owner_def_id( body. id( ) ) , closure_def_id) ;
@@ -361,7 +363,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
361363 // For coroutine-closures, we additionally must compute the
362364 // `coroutine_captures_by_ref_ty` type, which is used to generate the by-ref
363365 // version of the coroutine-closure's output coroutine.
364- if let UpvarArgs :: CoroutineClosure ( args) = args {
366+ if let UpvarArgs :: CoroutineClosure ( args) = args
367+ && !args. references_error ( )
368+ {
365369 let closure_env_region: ty:: Region < ' _ > = ty:: Region :: new_bound (
366370 self . tcx ,
367371 ty:: INNERMOST ,
0 commit comments