@@ -147,7 +147,7 @@ impl<'tcx> MutVisitor<'tcx> for DerefArgVisitor<'tcx> {
147
147
}
148
148
149
149
struct PinArgVisitor < ' tcx > {
150
- ref_gen_ty : Ty < ' tcx > ,
150
+ ref_coroutine_ty : Ty < ' tcx > ,
151
151
tcx : TyCtxt < ' tcx > ,
152
152
}
153
153
@@ -168,7 +168,7 @@ impl<'tcx> MutVisitor<'tcx> for PinArgVisitor<'tcx> {
168
168
local : SELF_ARG ,
169
169
projection : self . tcx ( ) . mk_place_elems ( & [ ProjectionElem :: Field (
170
170
FieldIdx :: new ( 0 ) ,
171
- self . ref_gen_ty ,
171
+ self . ref_coroutine_ty ,
172
172
) ] ) ,
173
173
} ,
174
174
self . tcx ,
@@ -468,34 +468,34 @@ impl<'tcx> MutVisitor<'tcx> for TransformVisitor<'tcx> {
468
468
}
469
469
470
470
fn 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 ;
472
472
473
- let ref_gen_ty = Ty :: new_ref (
473
+ let ref_coroutine_ty = Ty :: new_ref (
474
474
tcx,
475
475
tcx. lifetimes . re_erased ,
476
- ty:: TypeAndMut { ty : gen_ty , mutbl : Mutability :: Mut } ,
476
+ ty:: TypeAndMut { ty : coroutine_ty , mutbl : Mutability :: Mut } ,
477
477
) ;
478
478
479
479
// 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 ;
481
481
482
482
// Add a deref to accesses of the coroutine state
483
483
DerefArgVisitor { tcx } . visit_body ( body) ;
484
484
}
485
485
486
486
fn 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 ;
488
488
489
489
let pin_did = tcx. require_lang_item ( LangItem :: Pin , Some ( body. span ) ) ;
490
490
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) ;
493
493
494
494
// 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 ;
496
496
497
497
// 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) ;
499
499
}
500
500
501
501
/// 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>) {
1104
1104
fn create_coroutine_drop_shim < ' tcx > (
1105
1105
tcx : TyCtxt < ' tcx > ,
1106
1106
transform : & TransformVisitor < ' tcx > ,
1107
- gen_ty : Ty < ' tcx > ,
1107
+ coroutine_ty : Ty < ' tcx > ,
1108
1108
body : & mut Body < ' tcx > ,
1109
1109
drop_clean : BasicBlock ,
1110
1110
) -> Body < ' tcx > {
@@ -1136,7 +1136,7 @@ fn create_coroutine_drop_shim<'tcx>(
1136
1136
1137
1137
// Change the coroutine argument from &mut to *mut
1138
1138
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 } ) ,
1140
1140
source_info,
1141
1141
) ;
1142
1142
@@ -1146,9 +1146,9 @@ fn create_coroutine_drop_shim<'tcx>(
1146
1146
1147
1147
// Update the body's def to become the drop glue.
1148
1148
// This needs to be updated before the AbortUnwindingCalls pass.
1149
- let gen_instance = body. source . instance ;
1149
+ let coroutine_instance = body. source . instance ;
1150
1150
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 ) ) ;
1152
1152
body. source . instance = drop_instance;
1153
1153
1154
1154
pm:: run_passes_no_validate (
@@ -1160,7 +1160,7 @@ fn create_coroutine_drop_shim<'tcx>(
1160
1160
1161
1161
// Temporary change MirSource to coroutine's instance so that dump_mir produces more sensible
1162
1162
// filename.
1163
- body. source . instance = gen_instance ;
1163
+ body. source . instance = coroutine_instance ;
1164
1164
dump_mir ( tcx, false , "coroutine_drop" , & 0 , & body, |_, _| Ok ( ( ) ) ) ;
1165
1165
body. source . instance = drop_instance;
1166
1166
@@ -1447,13 +1447,13 @@ pub(crate) fn mir_coroutine_witnesses<'tcx>(
1447
1447
let body = & * body;
1448
1448
1449
1449
// 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 ;
1451
1451
1452
1452
// Get the interior types and args which typeck computed
1453
- let movable = match * gen_ty . kind ( ) {
1453
+ let movable = match * coroutine_ty . kind ( ) {
1454
1454
ty:: Coroutine ( _, _, movability) => movability == hir:: Movability :: Movable ,
1455
1455
ty:: Error ( _) => return None ,
1456
- _ => span_bug ! ( body. span, "unexpected coroutine type {}" , gen_ty ) ,
1456
+ _ => span_bug ! ( body. span, "unexpected coroutine type {}" , coroutine_ty ) ,
1457
1457
} ;
1458
1458
1459
1459
// When first entering the coroutine, move the resume argument into its new local.
@@ -1481,16 +1481,17 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
1481
1481
assert ! ( body. coroutine_drop( ) . is_none( ) ) ;
1482
1482
1483
1483
// 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 ;
1485
1485
1486
1486
// 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 ( ) {
1488
1488
ty:: Coroutine ( _, args, movability) => {
1489
1489
let args = args. as_coroutine ( ) ;
1490
1490
( args. discr_ty ( tcx) , movability == hir:: Movability :: Movable )
1491
1491
}
1492
1492
_ => {
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}" ) ) ;
1494
1495
return ;
1495
1496
}
1496
1497
} ;
@@ -1626,7 +1627,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
1626
1627
dump_mir ( tcx, false , "coroutine_post-transform" , & 0 , body, |_, _| Ok ( ( ) ) ) ;
1627
1628
1628
1629
// 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) ;
1630
1631
1631
1632
body. coroutine . as_mut ( ) . unwrap ( ) . coroutine_drop = Some ( drop_shim) ;
1632
1633
0 commit comments