@@ -422,49 +422,53 @@ pub fn analyze_coroutine_closure_captures<'a, 'tcx: 'a, T>(
422
422
child_captures : impl IntoIterator < Item = & ' a CapturedPlace < ' tcx > > ,
423
423
mut for_each : impl FnMut ( ( usize , & ' a CapturedPlace < ' tcx > ) , ( usize , & ' a CapturedPlace < ' tcx > ) ) -> T ,
424
424
) -> impl Iterator < Item = T > + Captures < ' a > + Captures < ' tcx > {
425
- std:: iter:: from_coroutine ( move || {
426
- let mut child_captures = child_captures. into_iter ( ) . enumerate ( ) . peekable ( ) ;
427
-
428
- // One parent capture may correspond to several child captures if we end up
429
- // refining the set of captures via edition-2021 precise captures. We want to
430
- // match up any number of child captures with one parent capture, so we keep
431
- // peeking off this `Peekable` until the child doesn't match anymore.
432
- for ( parent_field_idx, parent_capture) in parent_captures. into_iter ( ) . enumerate ( ) {
433
- // Make sure we use every field at least once, b/c why are we capturing something
434
- // if it's not used in the inner coroutine.
435
- let mut field_used_at_least_once = false ;
436
-
437
- // A parent matches a child if they share the same prefix of projections.
438
- // The child may have more, if it is capturing sub-fields out of
439
- // something that is captured by-move in the parent closure.
440
- while child_captures. peek ( ) . map_or ( false , |( _, child_capture) | {
441
- child_prefix_matches_parent_projections ( parent_capture, child_capture)
442
- } ) {
443
- let ( child_field_idx, child_capture) = child_captures. next ( ) . unwrap ( ) ;
444
- // This analysis only makes sense if the parent capture is a
445
- // prefix of the child capture.
446
- assert ! (
447
- child_capture. place. projections. len( ) >= parent_capture. place. projections. len( ) ,
448
- "parent capture ({parent_capture:#?}) expected to be prefix of \
425
+ std:: iter:: from_coroutine (
426
+ #[ cfg_attr( not( bootstrap) , coroutine) ]
427
+ move || {
428
+ let mut child_captures = child_captures. into_iter ( ) . enumerate ( ) . peekable ( ) ;
429
+
430
+ // One parent capture may correspond to several child captures if we end up
431
+ // refining the set of captures via edition-2021 precise captures. We want to
432
+ // match up any number of child captures with one parent capture, so we keep
433
+ // peeking off this `Peekable` until the child doesn't match anymore.
434
+ for ( parent_field_idx, parent_capture) in parent_captures. into_iter ( ) . enumerate ( ) {
435
+ // Make sure we use every field at least once, b/c why are we capturing something
436
+ // if it's not used in the inner coroutine.
437
+ let mut field_used_at_least_once = false ;
438
+
439
+ // A parent matches a child if they share the same prefix of projections.
440
+ // The child may have more, if it is capturing sub-fields out of
441
+ // something that is captured by-move in the parent closure.
442
+ while child_captures. peek ( ) . map_or ( false , |( _, child_capture) | {
443
+ child_prefix_matches_parent_projections ( parent_capture, child_capture)
444
+ } ) {
445
+ let ( child_field_idx, child_capture) = child_captures. next ( ) . unwrap ( ) ;
446
+ // This analysis only makes sense if the parent capture is a
447
+ // prefix of the child capture.
448
+ assert ! (
449
+ child_capture. place. projections. len( )
450
+ >= parent_capture. place. projections. len( ) ,
451
+ "parent capture ({parent_capture:#?}) expected to be prefix of \
449
452
child capture ({child_capture:#?})"
450
- ) ;
453
+ ) ;
451
454
452
- yield for_each (
453
- ( parent_field_idx, parent_capture) ,
454
- ( child_field_idx, child_capture) ,
455
- ) ;
455
+ yield for_each (
456
+ ( parent_field_idx, parent_capture) ,
457
+ ( child_field_idx, child_capture) ,
458
+ ) ;
456
459
457
- field_used_at_least_once = true ;
458
- }
460
+ field_used_at_least_once = true ;
461
+ }
459
462
460
- // Make sure the field was used at least once.
461
- assert ! (
462
- field_used_at_least_once,
463
- "we captured {parent_capture:#?} but it was not used in the child coroutine?"
464
- ) ;
465
- }
466
- assert_eq ! ( child_captures. next( ) , None , "leftover child captures?" ) ;
467
- } )
463
+ // Make sure the field was used at least once.
464
+ assert ! (
465
+ field_used_at_least_once,
466
+ "we captured {parent_capture:#?} but it was not used in the child coroutine?"
467
+ ) ;
468
+ }
469
+ assert_eq ! ( child_captures. next( ) , None , "leftover child captures?" ) ;
470
+ } ,
471
+ )
468
472
}
469
473
470
474
fn child_prefix_matches_parent_projections (
0 commit comments