@@ -137,45 +137,35 @@ impl InitializationData<'_, '_> {
137
137
}
138
138
}
139
139
140
- struct Elaborator < ' a , ' mir , ' tcx > {
141
- ctxt : & ' a mut ElaborateDropsCtxt < ' mir , ' tcx > ,
142
- }
143
-
144
- impl fmt:: Debug for Elaborator < ' _ , ' _ , ' _ > {
145
- fn fmt ( & self , _f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
146
- Ok ( ( ) )
147
- }
148
- }
149
-
150
- impl < ' mir , ' tcx > DropElaborator < ' mir , ' tcx > for Elaborator < ' _ , ' mir , ' tcx > {
140
+ impl < ' mir , ' tcx > DropElaborator < ' mir , ' tcx > for ElaborateDropsCtxt < ' mir , ' tcx > {
151
141
type Path = MovePathIndex ;
152
142
153
143
fn patch ( & mut self ) -> & mut MirPatch < ' tcx > {
154
- & mut self . ctxt . patch
144
+ & mut self . patch
155
145
}
156
146
157
147
fn body ( & self ) -> & ' mir Body < ' tcx > {
158
- self . ctxt . body
148
+ self . body
159
149
}
160
150
161
151
fn tcx ( & self ) -> TyCtxt < ' tcx > {
162
- self . ctxt . tcx
152
+ self . tcx
163
153
}
164
154
165
155
fn param_env ( & self ) -> ty:: ParamEnv < ' tcx > {
166
- self . ctxt . param_env ( )
156
+ self . param_env ( )
167
157
}
168
158
169
159
#[ instrument( level = "debug" , skip( self ) , ret) ]
170
160
fn drop_style ( & self , path : Self :: Path , mode : DropFlagMode ) -> DropStyle {
171
161
let ( ( maybe_live, maybe_dead) , multipart) = match mode {
172
- DropFlagMode :: Shallow => ( self . ctxt . init_data . maybe_live_dead ( path) , false ) ,
162
+ DropFlagMode :: Shallow => ( self . init_data . maybe_live_dead ( path) , false ) ,
173
163
DropFlagMode :: Deep => {
174
164
let mut some_live = false ;
175
165
let mut some_dead = false ;
176
166
let mut children_count = 0 ;
177
- on_all_children_bits ( self . ctxt . move_data ( ) , path, |child| {
178
- let ( live, dead) = self . ctxt . init_data . maybe_live_dead ( child) ;
167
+ on_all_children_bits ( self . move_data ( ) , path, |child| {
168
+ let ( live, dead) = self . init_data . maybe_live_dead ( child) ;
179
169
debug ! ( "elaborate_drop: state({:?}) = {:?}" , child, ( live, dead) ) ;
180
170
some_live |= live;
181
171
some_dead |= dead;
@@ -195,25 +185,25 @@ impl<'mir, 'tcx> DropElaborator<'mir, 'tcx> for Elaborator<'_, 'mir, 'tcx> {
195
185
fn clear_drop_flag ( & mut self , loc : Location , path : Self :: Path , mode : DropFlagMode ) {
196
186
match mode {
197
187
DropFlagMode :: Shallow => {
198
- self . ctxt . set_drop_flag ( loc, path, DropFlagState :: Absent ) ;
188
+ self . set_drop_flag ( loc, path, DropFlagState :: Absent ) ;
199
189
}
200
190
DropFlagMode :: Deep => {
201
- on_all_children_bits ( self . ctxt . move_data ( ) , path, |child| {
202
- self . ctxt . set_drop_flag ( loc, child, DropFlagState :: Absent )
191
+ on_all_children_bits ( self . move_data ( ) , path, |child| {
192
+ self . set_drop_flag ( loc, child, DropFlagState :: Absent )
203
193
} ) ;
204
194
}
205
195
}
206
196
}
207
197
208
198
fn field_subpath ( & self , path : Self :: Path , field : FieldIdx ) -> Option < Self :: Path > {
209
- rustc_mir_dataflow:: move_path_children_matching ( self . ctxt . move_data ( ) , path, |e| match e {
199
+ rustc_mir_dataflow:: move_path_children_matching ( self . move_data ( ) , path, |e| match e {
210
200
ProjectionElem :: Field ( idx, _) => idx == field,
211
201
_ => false ,
212
202
} )
213
203
}
214
204
215
205
fn array_subpath ( & self , path : Self :: Path , index : u64 , size : u64 ) -> Option < Self :: Path > {
216
- rustc_mir_dataflow:: move_path_children_matching ( self . ctxt . move_data ( ) , path, |e| match e {
206
+ rustc_mir_dataflow:: move_path_children_matching ( self . move_data ( ) , path, |e| match e {
217
207
ProjectionElem :: ConstantIndex { offset, min_length, from_end } => {
218
208
debug_assert ! ( size == min_length, "min_length should be exact for arrays" ) ;
219
209
assert ! ( !from_end, "from_end should not be used for array element ConstantIndex" ) ;
@@ -224,20 +214,20 @@ impl<'mir, 'tcx> DropElaborator<'mir, 'tcx> for Elaborator<'_, 'mir, 'tcx> {
224
214
}
225
215
226
216
fn deref_subpath ( & self , path : Self :: Path ) -> Option < Self :: Path > {
227
- rustc_mir_dataflow:: move_path_children_matching ( self . ctxt . move_data ( ) , path, |e| {
217
+ rustc_mir_dataflow:: move_path_children_matching ( self . move_data ( ) , path, |e| {
228
218
e == ProjectionElem :: Deref
229
219
} )
230
220
}
231
221
232
222
fn downcast_subpath ( & self , path : Self :: Path , variant : VariantIdx ) -> Option < Self :: Path > {
233
- rustc_mir_dataflow:: move_path_children_matching ( self . ctxt . move_data ( ) , path, |e| match e {
223
+ rustc_mir_dataflow:: move_path_children_matching ( self . move_data ( ) , path, |e| match e {
234
224
ProjectionElem :: Downcast ( _, idx) => idx == variant,
235
225
_ => false ,
236
226
} )
237
227
}
238
228
239
229
fn get_drop_flag ( & mut self , path : Self :: Path ) -> Option < Operand < ' tcx > > {
240
- self . ctxt . drop_flag ( path) . map ( Operand :: Copy )
230
+ self . drop_flag ( path) . map ( Operand :: Copy )
241
231
}
242
232
}
243
233
@@ -250,6 +240,12 @@ struct ElaborateDropsCtxt<'mir, 'tcx> {
250
240
patch : MirPatch < ' tcx > ,
251
241
}
252
242
243
+ impl fmt:: Debug for ElaborateDropsCtxt < ' _ , ' _ > {
244
+ fn fmt ( & self , _f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
245
+ Ok ( ( ) )
246
+ }
247
+ }
248
+
253
249
impl < ' mir , ' tcx > ElaborateDropsCtxt < ' mir , ' tcx > {
254
250
fn move_data ( & self ) -> & ' mir MoveData < ' tcx > {
255
251
& self . env . move_data
@@ -370,15 +366,7 @@ impl<'mir, 'tcx> ElaborateDropsCtxt<'mir, 'tcx> {
370
366
}
371
367
} ;
372
368
self . init_data . seek_before ( self . body . terminator_loc ( bb) ) ;
373
- elaborate_drop (
374
- & mut Elaborator { ctxt : self } ,
375
- terminator. source_info ,
376
- place,
377
- path,
378
- target,
379
- unwind,
380
- bb,
381
- )
369
+ elaborate_drop ( self , terminator. source_info , place, path, target, unwind, bb)
382
370
}
383
371
LookupResult :: Parent ( None ) => { }
384
372
LookupResult :: Parent ( Some ( _) ) => {
0 commit comments