@@ -357,18 +357,11 @@ impl MutVisitor<'tcx> for TransformVisitor<'tcx> {
357
357
}
358
358
}
359
359
360
- fn make_generator_state_argument_indirect < ' tcx > (
361
- tcx : TyCtxt < ' tcx > ,
362
- def_id : DefId ,
363
- body : & mut BodyAndCache < ' tcx > ,
364
- ) {
360
+ fn make_generator_state_argument_indirect < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & mut BodyAndCache < ' tcx > ) {
365
361
let gen_ty = body. local_decls . raw [ 1 ] . ty ;
366
362
367
- let region = ty:: ReFree ( ty:: FreeRegion { scope : def_id, bound_region : ty:: BoundRegion :: BrEnv } ) ;
368
-
369
- let region = tcx. mk_region ( region) ;
370
-
371
- let ref_gen_ty = tcx. mk_ref ( region, ty:: TypeAndMut { ty : gen_ty, mutbl : hir:: Mutability :: Mut } ) ;
363
+ let ref_gen_ty =
364
+ tcx. mk_ref ( tcx. lifetimes . re_erased , ty:: TypeAndMut { ty : gen_ty, mutbl : Mutability :: Mut } ) ;
372
365
373
366
// Replace the by value generator argument
374
367
body. local_decls . raw [ 1 ] . ty = ref_gen_ty;
@@ -874,7 +867,6 @@ fn elaborate_generator_drops<'tcx>(
874
867
fn create_generator_drop_shim < ' tcx > (
875
868
tcx : TyCtxt < ' tcx > ,
876
869
transform : & TransformVisitor < ' tcx > ,
877
- def_id : DefId ,
878
870
source : MirSource < ' tcx > ,
879
871
gen_ty : Ty < ' tcx > ,
880
872
body : & mut BodyAndCache < ' tcx > ,
@@ -912,7 +904,7 @@ fn create_generator_drop_shim<'tcx>(
912
904
local_info : LocalInfo :: Other ,
913
905
} ;
914
906
915
- make_generator_state_argument_indirect ( tcx, def_id , & mut body) ;
907
+ make_generator_state_argument_indirect ( tcx, & mut body) ;
916
908
917
909
// Change the generator argument from &mut to *mut
918
910
body. local_decls [ SELF_ARG ] = LocalDecl {
@@ -1047,7 +1039,6 @@ fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
1047
1039
fn create_generator_resume_function < ' tcx > (
1048
1040
tcx : TyCtxt < ' tcx > ,
1049
1041
transform : TransformVisitor < ' tcx > ,
1050
- def_id : DefId ,
1051
1042
source : MirSource < ' tcx > ,
1052
1043
body : & mut BodyAndCache < ' tcx > ,
1053
1044
can_return : bool ,
@@ -1112,7 +1103,7 @@ fn create_generator_resume_function<'tcx>(
1112
1103
1113
1104
insert_switch ( body, cases, & transform, TerminatorKind :: Unreachable ) ;
1114
1105
1115
- make_generator_state_argument_indirect ( tcx, def_id , body) ;
1106
+ make_generator_state_argument_indirect ( tcx, body) ;
1116
1107
make_generator_state_argument_pinned ( tcx, body) ;
1117
1108
1118
1109
no_landing_pads ( tcx, body) ;
@@ -1332,11 +1323,11 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
1332
1323
1333
1324
// Create a copy of our MIR and use it to create the drop shim for the generator
1334
1325
let drop_shim =
1335
- create_generator_drop_shim ( tcx, & transform, def_id , source, gen_ty, body, drop_clean) ;
1326
+ create_generator_drop_shim ( tcx, & transform, source, gen_ty, body, drop_clean) ;
1336
1327
1337
1328
body. generator_drop = Some ( box drop_shim) ;
1338
1329
1339
1330
// Create the Generator::resume function
1340
- create_generator_resume_function ( tcx, transform, def_id , source, body, can_return) ;
1331
+ create_generator_resume_function ( tcx, transform, source, body, can_return) ;
1341
1332
}
1342
1333
}
0 commit comments