11use crate :: elaborate_drops:: DropFlagState ;
22use rustc_middle:: mir:: { self , Body , Location , Terminator , TerminatorKind } ;
3- use rustc_middle:: ty:: TyCtxt ;
43use rustc_target:: abi:: VariantIdx ;
54
6- use super :: indexes:: MovePathIndex ;
7- use super :: move_paths:: { InitKind , LookupResult , MoveData } ;
5+ use super :: move_paths:: { InitKind , LookupResult , MoveData , MovePathIndex } ;
86use super :: MoveDataParamEnv ;
97
108pub fn move_path_children_matching < ' tcx , F > (
3028}
3129
3230pub fn on_lookup_result_bits < ' tcx , F > (
33- tcx : TyCtxt < ' tcx > ,
34- body : & Body < ' tcx > ,
3531 move_data : & MoveData < ' tcx > ,
3632 lookup_result : LookupResult ,
3733 each_child : F ,
@@ -42,22 +38,18 @@ pub fn on_lookup_result_bits<'tcx, F>(
4238 LookupResult :: Parent ( ..) => {
4339 // access to untracked value - do not touch children
4440 }
45- LookupResult :: Exact ( e) => on_all_children_bits ( tcx , body , move_data, e, each_child) ,
41+ LookupResult :: Exact ( e) => on_all_children_bits ( move_data, e, each_child) ,
4642 }
4743}
4844
4945pub fn on_all_children_bits < ' tcx , F > (
50- tcx : TyCtxt < ' tcx > ,
51- body : & Body < ' tcx > ,
5246 move_data : & MoveData < ' tcx > ,
5347 move_path_index : MovePathIndex ,
5448 mut each_child : F ,
5549) where
5650 F : FnMut ( MovePathIndex ) ,
5751{
5852 fn on_all_children_bits < ' tcx , F > (
59- tcx : TyCtxt < ' tcx > ,
60- body : & Body < ' tcx > ,
6153 move_data : & MoveData < ' tcx > ,
6254 move_path_index : MovePathIndex ,
6355 each_child : & mut F ,
@@ -68,15 +60,14 @@ pub fn on_all_children_bits<'tcx, F>(
6860
6961 let mut next_child_index = move_data. move_paths [ move_path_index] . first_child ;
7062 while let Some ( child_index) = next_child_index {
71- on_all_children_bits ( tcx , body , move_data, child_index, each_child) ;
63+ on_all_children_bits ( move_data, child_index, each_child) ;
7264 next_child_index = move_data. move_paths [ child_index] . next_sibling ;
7365 }
7466 }
75- on_all_children_bits ( tcx , body , move_data, move_path_index, & mut each_child) ;
67+ on_all_children_bits ( move_data, move_path_index, & mut each_child) ;
7668}
7769
7870pub fn drop_flag_effects_for_function_entry < ' tcx , F > (
79- tcx : TyCtxt < ' tcx > ,
8071 body : & Body < ' tcx > ,
8172 ctxt : & MoveDataParamEnv < ' tcx > ,
8273 mut callback : F ,
@@ -87,14 +78,13 @@ pub fn drop_flag_effects_for_function_entry<'tcx, F>(
8778 for arg in body. args_iter ( ) {
8879 let place = mir:: Place :: from ( arg) ;
8980 let lookup_result = move_data. rev_lookup . find ( place. as_ref ( ) ) ;
90- on_lookup_result_bits ( tcx , body , move_data, lookup_result, |mpi| {
81+ on_lookup_result_bits ( move_data, lookup_result, |mpi| {
9182 callback ( mpi, DropFlagState :: Present )
9283 } ) ;
9384 }
9485}
9586
9687pub fn drop_flag_effects_for_location < ' tcx , F > (
97- tcx : TyCtxt < ' tcx > ,
9888 body : & Body < ' tcx > ,
9989 ctxt : & MoveDataParamEnv < ' tcx > ,
10090 loc : Location ,
@@ -110,32 +100,25 @@ pub fn drop_flag_effects_for_location<'tcx, F>(
110100 let path = mi. move_path_index ( move_data) ;
111101 debug ! ( "moving out of path {:?}" , move_data. move_paths[ path] ) ;
112102
113- on_all_children_bits ( tcx , body , move_data, path, |mpi| callback ( mpi, DropFlagState :: Absent ) )
103+ on_all_children_bits ( move_data, path, |mpi| callback ( mpi, DropFlagState :: Absent ) )
114104 }
115105
116106 // Drop does not count as a move but we should still consider the variable uninitialized.
117107 if let Some ( Terminator { kind : TerminatorKind :: Drop { place, .. } , .. } ) =
118108 body. stmt_at ( loc) . right ( )
119109 {
120110 if let LookupResult :: Exact ( mpi) = move_data. rev_lookup . find ( place. as_ref ( ) ) {
121- on_all_children_bits ( tcx, body, move_data, mpi, |mpi| {
122- callback ( mpi, DropFlagState :: Absent )
123- } )
111+ on_all_children_bits ( move_data, mpi, |mpi| callback ( mpi, DropFlagState :: Absent ) )
124112 }
125113 }
126114
127115 debug ! ( "drop_flag_effects: assignment for location({:?})" , loc) ;
128116
129- for_location_inits ( tcx , body , move_data, loc, |mpi| callback ( mpi, DropFlagState :: Present ) ) ;
117+ for_location_inits ( move_data, loc, |mpi| callback ( mpi, DropFlagState :: Present ) ) ;
130118}
131119
132- pub fn for_location_inits < ' tcx , F > (
133- tcx : TyCtxt < ' tcx > ,
134- body : & Body < ' tcx > ,
135- move_data : & MoveData < ' tcx > ,
136- loc : Location ,
137- mut callback : F ,
138- ) where
120+ fn for_location_inits < ' tcx , F > ( move_data : & MoveData < ' tcx > , loc : Location , mut callback : F )
121+ where
139122 F : FnMut ( MovePathIndex ) ,
140123{
141124 for ii in & move_data. init_loc_map [ loc] {
@@ -144,7 +127,7 @@ pub fn for_location_inits<'tcx, F>(
144127 InitKind :: Deep => {
145128 let path = init. path ;
146129
147- on_all_children_bits ( tcx , body , move_data, path, & mut callback)
130+ on_all_children_bits ( move_data, path, & mut callback)
148131 }
149132 InitKind :: Shallow => {
150133 let mpi = init. path ;
@@ -161,8 +144,6 @@ pub fn for_location_inits<'tcx, F>(
161144/// NOTE: If there are no move paths corresponding to an inactive variant,
162145/// `handle_inactive_variant` will not be called for that variant.
163146pub ( crate ) fn on_all_inactive_variants < ' tcx > (
164- tcx : TyCtxt < ' tcx > ,
165- body : & mir:: Body < ' tcx > ,
166147 move_data : & MoveData < ' tcx > ,
167148 enum_place : mir:: Place < ' tcx > ,
168149 active_variant : VariantIdx ,
@@ -185,9 +166,7 @@ pub(crate) fn on_all_inactive_variants<'tcx>(
185166 } ;
186167
187168 if variant_idx != active_variant {
188- on_all_children_bits ( tcx, body, move_data, variant_mpi, |mpi| {
189- handle_inactive_variant ( mpi)
190- } ) ;
169+ on_all_children_bits ( move_data, variant_mpi, |mpi| handle_inactive_variant ( mpi) ) ;
191170 }
192171 }
193172}
0 commit comments