@@ -43,7 +43,8 @@ use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection, Pro
43
43
use rustc_middle:: mir:: FakeReadCause ;
44
44
use rustc_middle:: traits:: ObligationCauseCode ;
45
45
use rustc_middle:: ty:: {
46
- self , ClosureSizeProfileData , Ty , TyCtxt , TypeckResults , UpvarArgs , UpvarCapture ,
46
+ self , ClosureSizeProfileData , Ty , TyCtxt , TypeVisitableExt as _, TypeckResults , UpvarArgs ,
47
+ UpvarCapture ,
47
48
} ;
48
49
use rustc_session:: lint;
49
50
use rustc_span:: sym;
@@ -191,6 +192,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
191
192
) ;
192
193
}
193
194
} ;
195
+ let args = self . resolve_vars_if_possible ( args) ;
194
196
let closure_def_id = closure_def_id. expect_local ( ) ;
195
197
196
198
assert_eq ! ( self . tcx. hir( ) . body_owner_def_id( body. id( ) ) , closure_def_id) ;
@@ -361,7 +363,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
361
363
// For coroutine-closures, we additionally must compute the
362
364
// `coroutine_captures_by_ref_ty` type, which is used to generate the by-ref
363
365
// 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
+ {
365
369
let closure_env_region: ty:: Region < ' _ > = ty:: Region :: new_bound (
366
370
self . tcx ,
367
371
ty:: INNERMOST ,
0 commit comments