@@ -13,7 +13,7 @@ use rustc_hir::def_id::LocalDefId;
13
13
use rustc_hir:: HirId ;
14
14
use rustc_span:: def_id:: LocalDefIdMap ;
15
15
use rustc_span:: symbol:: Ident ;
16
- use rustc_span:: { Span , Symbol } ;
16
+ use rustc_span:: { Span , Symbol , DUMMY_SP } ;
17
17
18
18
use super :: TyCtxt ;
19
19
@@ -418,6 +418,7 @@ impl BorrowKind {
418
418
}
419
419
420
420
pub fn analyze_coroutine_closure_captures < ' a , ' tcx : ' a , T > (
421
+ tcx : TyCtxt < ' tcx > ,
421
422
parent_captures : impl IntoIterator < Item = & ' a CapturedPlace < ' tcx > > ,
422
423
child_captures : impl IntoIterator < Item = & ' a CapturedPlace < ' tcx > > ,
423
424
mut for_each : impl FnMut ( ( usize , & ' a CapturedPlace < ' tcx > ) , ( usize , & ' a CapturedPlace < ' tcx > ) ) -> T ,
@@ -466,7 +467,13 @@ pub fn analyze_coroutine_closure_captures<'a, 'tcx: 'a, T>(
466
467
"we captured {parent_capture:#?} but it was not used in the child coroutine?"
467
468
) ;
468
469
}
469
- assert_eq ! ( child_captures. next( ) , None , "leftover child captures?" ) ;
470
+
471
+ if let Some ( ( _, capture) ) = child_captures. next ( ) {
472
+ tcx. dcx ( ) . span_delayed_bug (
473
+ capture. info . path_expr_id . map_or ( DUMMY_SP , |hir_id| tcx. hir ( ) . span ( hir_id) ) ,
474
+ "leftover child captures: expecting an error" ,
475
+ ) ;
476
+ }
470
477
} ,
471
478
)
472
479
}
0 commit comments