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