@@ -147,7 +147,7 @@ impl<'tcx> MutVisitor<'tcx> for DerefArgVisitor<'tcx> {
147147}
148148
149149struct PinArgVisitor < ' tcx > {
150- ref_gen_ty : Ty < ' tcx > ,
150+ ref_coroutine_ty : Ty < ' tcx > ,
151151 tcx : TyCtxt < ' tcx > ,
152152}
153153
@@ -168,7 +168,7 @@ impl<'tcx> MutVisitor<'tcx> for PinArgVisitor<'tcx> {
168168 local : SELF_ARG ,
169169 projection : self . tcx ( ) . mk_place_elems ( & [ ProjectionElem :: Field (
170170 FieldIdx :: new ( 0 ) ,
171- self . ref_gen_ty ,
171+ self . ref_coroutine_ty ,
172172 ) ] ) ,
173173 } ,
174174 self . tcx ,
@@ -468,34 +468,34 @@ impl<'tcx> MutVisitor<'tcx> for TransformVisitor<'tcx> {
468468}
469469
470470fn make_coroutine_state_argument_indirect < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
471- let gen_ty = body. local_decls . raw [ 1 ] . ty ;
471+ let coroutine_ty = body. local_decls . raw [ 1 ] . ty ;
472472
473- let ref_gen_ty = Ty :: new_ref (
473+ let ref_coroutine_ty = Ty :: new_ref (
474474 tcx,
475475 tcx. lifetimes . re_erased ,
476- ty:: TypeAndMut { ty : gen_ty , mutbl : Mutability :: Mut } ,
476+ ty:: TypeAndMut { ty : coroutine_ty , mutbl : Mutability :: Mut } ,
477477 ) ;
478478
479479 // Replace the by value coroutine argument
480- body. local_decls . raw [ 1 ] . ty = ref_gen_ty ;
480+ body. local_decls . raw [ 1 ] . ty = ref_coroutine_ty ;
481481
482482 // Add a deref to accesses of the coroutine state
483483 DerefArgVisitor { tcx } . visit_body ( body) ;
484484}
485485
486486fn make_coroutine_state_argument_pinned < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
487- let ref_gen_ty = body. local_decls . raw [ 1 ] . ty ;
487+ let ref_coroutine_ty = body. local_decls . raw [ 1 ] . ty ;
488488
489489 let pin_did = tcx. require_lang_item ( LangItem :: Pin , Some ( body. span ) ) ;
490490 let pin_adt_ref = tcx. adt_def ( pin_did) ;
491- let args = tcx. mk_args ( & [ ref_gen_ty . into ( ) ] ) ;
492- let pin_ref_gen_ty = Ty :: new_adt ( tcx, pin_adt_ref, args) ;
491+ let args = tcx. mk_args ( & [ ref_coroutine_ty . into ( ) ] ) ;
492+ let pin_ref_coroutine_ty = Ty :: new_adt ( tcx, pin_adt_ref, args) ;
493493
494494 // Replace the by ref coroutine argument
495- body. local_decls . raw [ 1 ] . ty = pin_ref_gen_ty ;
495+ body. local_decls . raw [ 1 ] . ty = pin_ref_coroutine_ty ;
496496
497497 // Add the Pin field access to accesses of the coroutine state
498- PinArgVisitor { ref_gen_ty , tcx } . visit_body ( body) ;
498+ PinArgVisitor { ref_coroutine_ty , tcx } . visit_body ( body) ;
499499}
500500
501501/// Allocates a new local and replaces all references of `local` with it. Returns the new local.
@@ -1104,7 +1104,7 @@ fn elaborate_coroutine_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
11041104fn create_coroutine_drop_shim < ' tcx > (
11051105 tcx : TyCtxt < ' tcx > ,
11061106 transform : & TransformVisitor < ' tcx > ,
1107- gen_ty : Ty < ' tcx > ,
1107+ coroutine_ty : Ty < ' tcx > ,
11081108 body : & mut Body < ' tcx > ,
11091109 drop_clean : BasicBlock ,
11101110) -> Body < ' tcx > {
@@ -1136,7 +1136,7 @@ fn create_coroutine_drop_shim<'tcx>(
11361136
11371137 // Change the coroutine argument from &mut to *mut
11381138 body. local_decls [ SELF_ARG ] = LocalDecl :: with_source_info (
1139- Ty :: new_ptr ( tcx, ty:: TypeAndMut { ty : gen_ty , mutbl : hir:: Mutability :: Mut } ) ,
1139+ Ty :: new_ptr ( tcx, ty:: TypeAndMut { ty : coroutine_ty , mutbl : hir:: Mutability :: Mut } ) ,
11401140 source_info,
11411141 ) ;
11421142
@@ -1146,9 +1146,9 @@ fn create_coroutine_drop_shim<'tcx>(
11461146
11471147 // Update the body's def to become the drop glue.
11481148 // This needs to be updated before the AbortUnwindingCalls pass.
1149- let gen_instance = body. source . instance ;
1149+ let coroutine_instance = body. source . instance ;
11501150 let drop_in_place = tcx. require_lang_item ( LangItem :: DropInPlace , None ) ;
1151- let drop_instance = InstanceDef :: DropGlue ( drop_in_place, Some ( gen_ty ) ) ;
1151+ let drop_instance = InstanceDef :: DropGlue ( drop_in_place, Some ( coroutine_ty ) ) ;
11521152 body. source . instance = drop_instance;
11531153
11541154 pm:: run_passes_no_validate (
@@ -1160,7 +1160,7 @@ fn create_coroutine_drop_shim<'tcx>(
11601160
11611161 // Temporary change MirSource to coroutine's instance so that dump_mir produces more sensible
11621162 // filename.
1163- body. source . instance = gen_instance ;
1163+ body. source . instance = coroutine_instance ;
11641164 dump_mir ( tcx, false , "coroutine_drop" , & 0 , & body, |_, _| Ok ( ( ) ) ) ;
11651165 body. source . instance = drop_instance;
11661166
@@ -1447,13 +1447,13 @@ pub(crate) fn mir_coroutine_witnesses<'tcx>(
14471447 let body = & * body;
14481448
14491449 // The first argument is the coroutine type passed by value
1450- let gen_ty = body. local_decls [ ty:: CAPTURE_STRUCT_LOCAL ] . ty ;
1450+ let coroutine_ty = body. local_decls [ ty:: CAPTURE_STRUCT_LOCAL ] . ty ;
14511451
14521452 // Get the interior types and args which typeck computed
1453- let movable = match * gen_ty . kind ( ) {
1453+ let movable = match * coroutine_ty . kind ( ) {
14541454 ty:: Coroutine ( _, _, movability) => movability == hir:: Movability :: Movable ,
14551455 ty:: Error ( _) => return None ,
1456- _ => span_bug ! ( body. span, "unexpected coroutine type {}" , gen_ty ) ,
1456+ _ => span_bug ! ( body. span, "unexpected coroutine type {}" , coroutine_ty ) ,
14571457 } ;
14581458
14591459 // When first entering the coroutine, move the resume argument into its new local.
@@ -1481,16 +1481,17 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
14811481 assert ! ( body. coroutine_drop( ) . is_none( ) ) ;
14821482
14831483 // The first argument is the coroutine type passed by value
1484- let gen_ty = body. local_decls . raw [ 1 ] . ty ;
1484+ let coroutine_ty = body. local_decls . raw [ 1 ] . ty ;
14851485
14861486 // Get the discriminant type and args which typeck computed
1487- let ( discr_ty, movable) = match * gen_ty . kind ( ) {
1487+ let ( discr_ty, movable) = match * coroutine_ty . kind ( ) {
14881488 ty:: Coroutine ( _, args, movability) => {
14891489 let args = args. as_coroutine ( ) ;
14901490 ( args. discr_ty ( tcx) , movability == hir:: Movability :: Movable )
14911491 }
14921492 _ => {
1493- tcx. sess . delay_span_bug ( body. span , format ! ( "unexpected coroutine type {gen_ty}" ) ) ;
1493+ tcx. sess
1494+ . delay_span_bug ( body. span , format ! ( "unexpected coroutine type {coroutine_ty}" ) ) ;
14941495 return ;
14951496 }
14961497 } ;
@@ -1626,7 +1627,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
16261627 dump_mir ( tcx, false , "coroutine_post-transform" , & 0 , body, |_, _| Ok ( ( ) ) ) ;
16271628
16281629 // Create a copy of our MIR and use it to create the drop shim for the coroutine
1629- let drop_shim = create_coroutine_drop_shim ( tcx, & transform, gen_ty , body, drop_clean) ;
1630+ let drop_shim = create_coroutine_drop_shim ( tcx, & transform, coroutine_ty , body, drop_clean) ;
16301631
16311632 body. coroutine . as_mut ( ) . unwrap ( ) . coroutine_drop = Some ( drop_shim) ;
16321633
0 commit comments