@@ -156,15 +156,6 @@ fn replace_base<'tcx>(place: &mut Place<'tcx>, new_base: Place<'tcx>, tcx: TyCtx
156156
157157const SELF_ARG : Local = Local :: from_u32 ( 1 ) ;
158158
159- /// Coroutine has not been resumed yet.
160- const UNRESUMED : usize = CoroutineArgs :: UNRESUMED ;
161- /// Coroutine has returned / is completed.
162- const RETURNED : usize = CoroutineArgs :: RETURNED ;
163- /// Coroutine has panicked and is poisoned.
164- const POISONED : usize = CoroutineArgs :: POISONED ;
165- /// Number of reserved variants of coroutine state.
166- const RESERVED_VARIANTS : usize = CoroutineArgs :: RESERVED_VARIANTS ;
167-
168159/// A `yield` point in the coroutine.
169160struct SuspensionPoint < ' tcx > {
170161 /// State discriminant used when suspending or resuming at this point.
@@ -475,7 +466,7 @@ impl<'tcx> MutVisitor<'tcx> for TransformVisitor<'tcx> {
475466 self . make_state ( v, source_info, is_return, & mut data. statements ) ;
476467 let state = if let Some ( ( resume, mut resume_arg) ) = resume {
477468 // Yield
478- let state = RESERVED_VARIANTS + self . suspension_points . len ( ) ;
469+ let state = CoroutineArgs :: RESERVED_VARIANTS + self . suspension_points . len ( ) ;
479470
480471 // The resume arg target location might itself be remapped if its base local is
481472 // live across a yield.
@@ -508,7 +499,7 @@ impl<'tcx> MutVisitor<'tcx> for TransformVisitor<'tcx> {
508499 VariantIdx :: new ( state)
509500 } else {
510501 // Return
511- VariantIdx :: new ( RETURNED ) // state for returned
502+ VariantIdx :: new ( CoroutineArgs :: RETURNED ) // state for returned
512503 } ;
513504 data. statements . push ( self . set_discr ( state, source_info) ) ;
514505 data. terminator_mut ( ) . kind = TerminatorKind :: Return ;
@@ -1044,10 +1035,11 @@ fn compute_layout<'tcx>(
10441035 // Build the coroutine variant field list.
10451036 // Create a map from local indices to coroutine struct indices.
10461037 let mut variant_fields: IndexVec < VariantIdx , IndexVec < FieldIdx , CoroutineSavedLocal > > =
1047- iter:: repeat ( IndexVec :: new ( ) ) . take ( RESERVED_VARIANTS ) . collect ( ) ;
1038+ iter:: repeat ( IndexVec :: new ( ) ) . take ( CoroutineArgs :: RESERVED_VARIANTS ) . collect ( ) ;
10481039 let mut remap = IndexVec :: from_elem_n ( None , saved_locals. domain_size ( ) ) ;
10491040 for ( suspension_point_idx, live_locals) in live_locals_at_suspension_points. iter ( ) . enumerate ( ) {
1050- let variant_index = VariantIdx :: from ( RESERVED_VARIANTS + suspension_point_idx) ;
1041+ let variant_index =
1042+ VariantIdx :: from ( CoroutineArgs :: RESERVED_VARIANTS + suspension_point_idx) ;
10511043 let mut fields = IndexVec :: new ( ) ;
10521044 for ( idx, saved_local) in live_locals. iter ( ) . enumerate ( ) {
10531045 fields. push ( saved_local) ;
@@ -1194,7 +1186,7 @@ fn create_coroutine_drop_shim<'tcx>(
11941186
11951187 let mut cases = create_cases ( & mut body, transform, Operation :: Drop ) ;
11961188
1197- cases. insert ( 0 , ( UNRESUMED , drop_clean) ) ;
1189+ cases. insert ( 0 , ( CoroutineArgs :: UNRESUMED , drop_clean) ) ;
11981190
11991191 // The returned state and the poisoned state fall through to the default
12001192 // case which is just to return
@@ -1344,7 +1336,9 @@ fn create_coroutine_resume_function<'tcx>(
13441336 if can_unwind {
13451337 let source_info = SourceInfo :: outermost ( body. span ) ;
13461338 let poison_block = body. basic_blocks_mut ( ) . push ( BasicBlockData {
1347- statements : vec ! [ transform. set_discr( VariantIdx :: new( POISONED ) , source_info) ] ,
1339+ statements : vec ! [
1340+ transform. set_discr( VariantIdx :: new( CoroutineArgs :: POISONED ) , source_info) ,
1341+ ] ,
13481342 terminator : Some ( Terminator { source_info, kind : TerminatorKind :: UnwindResume } ) ,
13491343 is_cleanup : true ,
13501344 } ) ;
@@ -1376,13 +1370,16 @@ fn create_coroutine_resume_function<'tcx>(
13761370 use rustc_middle:: mir:: AssertKind :: { ResumedAfterPanic , ResumedAfterReturn } ;
13771371
13781372 // Jump to the entry point on the unresumed
1379- cases. insert ( 0 , ( UNRESUMED , START_BLOCK ) ) ;
1373+ cases. insert ( 0 , ( CoroutineArgs :: UNRESUMED , START_BLOCK ) ) ;
13801374
13811375 // Panic when resumed on the returned or poisoned state
13821376 if can_unwind {
13831377 cases. insert (
13841378 1 ,
1385- ( POISONED , insert_panic_block ( tcx, body, ResumedAfterPanic ( transform. coroutine_kind ) ) ) ,
1379+ (
1380+ CoroutineArgs :: POISONED ,
1381+ insert_panic_block ( tcx, body, ResumedAfterPanic ( transform. coroutine_kind ) ) ,
1382+ ) ,
13861383 ) ;
13871384 }
13881385
@@ -1397,7 +1394,7 @@ fn create_coroutine_resume_function<'tcx>(
13971394 transform. insert_none_ret_block ( body)
13981395 }
13991396 } ;
1400- cases. insert ( 1 , ( RETURNED , block) ) ;
1397+ cases. insert ( 1 , ( CoroutineArgs :: RETURNED , block) ) ;
14011398 }
14021399
14031400 insert_switch ( body, cases, & transform, TerminatorKind :: Unreachable ) ;
0 commit comments