@@ -126,14 +126,14 @@ fn self_arg() -> Local {
126126 Local :: new ( 1 )
127127}
128128
129- struct SuspensionPoint {
129+ struct SuspensionPoint < V : Idx > {
130130 state : u32 ,
131131 resume : BasicBlock ,
132132 drop : Option < BasicBlock > ,
133- storage_liveness : liveness:: LocalSet ,
133+ storage_liveness : liveness:: LocalSet < V > ,
134134}
135135
136- struct TransformVisitor < ' a , ' tcx : ' a > {
136+ struct TransformVisitor < ' a , ' tcx : ' a , V : Idx > {
137137 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
138138 state_adt_ref : & ' tcx AdtDef ,
139139 state_substs : & ' tcx Substs < ' tcx > ,
@@ -145,16 +145,16 @@ struct TransformVisitor<'a, 'tcx: 'a> {
145145 remap : HashMap < Local , ( Ty < ' tcx > , usize ) > ,
146146
147147 // A map from a suspension point in a block to the locals which have live storage at that point
148- storage_liveness : HashMap < BasicBlock , liveness:: LocalSet > ,
148+ storage_liveness : HashMap < BasicBlock , liveness:: LocalSet < V > > ,
149149
150150 // A list of suspension points, generated during the transform
151- suspension_points : Vec < SuspensionPoint > ,
151+ suspension_points : Vec < SuspensionPoint < V > > ,
152152
153153 // The original RETURN_PLACE local
154154 new_ret_local : Local ,
155155}
156156
157- impl < ' a , ' tcx > TransformVisitor < ' a , ' tcx > {
157+ impl < ' a , ' tcx , V : Idx > TransformVisitor < ' a , ' tcx , V > {
158158 // Make a GeneratorState rvalue
159159 fn make_state ( & self , idx : usize , val : Operand < ' tcx > ) -> Rvalue < ' tcx > {
160160 let adt = AggregateKind :: Adt ( self . state_adt_ref , idx, self . state_substs , None ) ;
@@ -191,7 +191,7 @@ impl<'a, 'tcx> TransformVisitor<'a, 'tcx> {
191191 }
192192}
193193
194- impl < ' a , ' tcx > MutVisitor < ' tcx > for TransformVisitor < ' a , ' tcx > {
194+ impl < ' a , ' tcx , V : Idx > MutVisitor < ' tcx > for TransformVisitor < ' a , ' tcx , V > {
195195 fn visit_local ( & mut self ,
196196 local : & mut Local ,
197197 _: PlaceContext < ' tcx > ,
@@ -317,9 +317,9 @@ fn replace_result_variable<'tcx>(ret_ty: Ty<'tcx>,
317317 new_ret_local
318318}
319319
320- struct StorageIgnored ( liveness:: LocalSet ) ;
320+ struct StorageIgnored < V : Idx > ( liveness:: LocalSet < V > ) ;
321321
322- impl < ' tcx > Visitor < ' tcx > for StorageIgnored {
322+ impl < ' tcx , V : Idx > Visitor < ' tcx > for StorageIgnored < V > {
323323 fn visit_statement ( & mut self ,
324324 _block : BasicBlock ,
325325 statement : & Statement < ' tcx > ,
@@ -332,9 +332,9 @@ impl<'tcx> Visitor<'tcx> for StorageIgnored {
332332 }
333333}
334334
335- struct BorrowedLocals ( liveness:: LocalSet ) ;
335+ struct BorrowedLocals < V : Idx > ( liveness:: LocalSet < V > ) ;
336336
337- fn mark_as_borrowed < ' tcx > ( place : & Place < ' tcx > , locals : & mut BorrowedLocals ) {
337+ fn mark_as_borrowed < ' tcx , V : Idx > ( place : & Place < ' tcx > , locals : & mut BorrowedLocals < V > ) {
338338 match * place {
339339 Place :: Local ( l) => { locals. 0 . add ( & l) ; } ,
340340 Place :: Static ( ..) => ( ) ,
@@ -349,7 +349,7 @@ fn mark_as_borrowed<'tcx>(place: &Place<'tcx>, locals: &mut BorrowedLocals) {
349349 }
350350}
351351
352- impl < ' tcx > Visitor < ' tcx > for BorrowedLocals {
352+ impl < ' tcx , V : Idx > Visitor < ' tcx > for BorrowedLocals < V > {
353353 fn visit_rvalue ( & mut self ,
354354 rvalue : & Rvalue < ' tcx > ,
355355 location : Location ) {
@@ -361,12 +361,12 @@ impl<'tcx> Visitor<'tcx> for BorrowedLocals {
361361 }
362362}
363363
364- fn locals_live_across_suspend_points < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
364+ fn locals_live_across_suspend_points < ' a , ' tcx , V : Idx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
365365 mir : & Mir < ' tcx > ,
366366 source : MirSource ,
367367 movable : bool ) ->
368- ( liveness:: LocalSet ,
369- HashMap < BasicBlock , liveness:: LocalSet > ) {
368+ ( liveness:: LocalSet < V > ,
369+ HashMap < BasicBlock , liveness:: LocalSet < V > > ) {
370370 let dead_unwinds = IdxSetBuf :: new_empty ( mir. basic_blocks ( ) . len ( ) ) ;
371371 let node_id = tcx. hir . as_local_node_id ( source. def_id ) . unwrap ( ) ;
372372
@@ -460,15 +460,15 @@ fn locals_live_across_suspend_points<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
460460 ( set, storage_liveness_map)
461461}
462462
463- fn compute_layout < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
463+ fn compute_layout < ' a , ' tcx , V : Idx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
464464 source : MirSource ,
465465 upvars : Vec < Ty < ' tcx > > ,
466466 interior : Ty < ' tcx > ,
467467 movable : bool ,
468468 mir : & mut Mir < ' tcx > )
469469 -> ( HashMap < Local , ( Ty < ' tcx > , usize ) > ,
470470 GeneratorLayout < ' tcx > ,
471- HashMap < BasicBlock , liveness:: LocalSet > )
471+ HashMap < BasicBlock , liveness:: LocalSet < V > > )
472472{
473473 // Use a liveness analysis to compute locals which are live across a suspension point
474474 let ( live_locals, storage_liveness) = locals_live_across_suspend_points ( tcx,
@@ -524,10 +524,10 @@ fn compute_layout<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
524524 ( remap, layout, storage_liveness)
525525}
526526
527- fn insert_switch < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
527+ fn insert_switch < ' a , ' tcx , V : Idx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
528528 mir : & mut Mir < ' tcx > ,
529529 cases : Vec < ( u32 , BasicBlock ) > ,
530- transform : & TransformVisitor < ' a , ' tcx > ,
530+ transform : & TransformVisitor < ' a , ' tcx , V > ,
531531 default : TerminatorKind < ' tcx > ) {
532532 let default_block = insert_term_block ( mir, default) ;
533533
@@ -608,9 +608,9 @@ fn elaborate_generator_drops<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
608608 }
609609}
610610
611- fn create_generator_drop_shim < ' a , ' tcx > (
611+ fn create_generator_drop_shim < ' a , ' tcx , V : Idx > (
612612 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
613- transform : & TransformVisitor < ' a , ' tcx > ,
613+ transform : & TransformVisitor < ' a , ' tcx , V > ,
614614 def_id : DefId ,
615615 source : MirSource ,
616616 gen_ty : Ty < ' tcx > ,
@@ -719,9 +719,9 @@ fn insert_panic_block<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
719719 assert_block
720720}
721721
722- fn create_generator_resume_function < ' a , ' tcx > (
722+ fn create_generator_resume_function < ' a , ' tcx , V : Idx > (
723723 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
724- transform : TransformVisitor < ' a , ' tcx > ,
724+ transform : TransformVisitor < ' a , ' tcx , V > ,
725725 def_id : DefId ,
726726 source : MirSource ,
727727 mir : & mut Mir < ' tcx > ) {
@@ -790,10 +790,10 @@ fn insert_clean_drop<'a, 'tcx>(mir: &mut Mir<'tcx>) -> BasicBlock {
790790 drop_clean
791791}
792792
793- fn create_cases < ' a , ' tcx , F > ( mir : & mut Mir < ' tcx > ,
794- transform : & TransformVisitor < ' a , ' tcx > ,
793+ fn create_cases < ' a , ' tcx , F , V : Idx > ( mir : & mut Mir < ' tcx > ,
794+ transform : & TransformVisitor < ' a , ' tcx , V > ,
795795 target : F ) -> Vec < ( u32 , BasicBlock ) >
796- where F : Fn ( & SuspensionPoint ) -> Option < BasicBlock > {
796+ where F : Fn ( & SuspensionPoint < V > ) -> Option < BasicBlock > {
797797 let source_info = source_info ( mir) ;
798798
799799 transform. suspension_points . iter ( ) . filter_map ( |point| {
0 commit comments