Skip to content

Commit 0b032f8

Browse files
committed
Remove Elaborator.
It's a trivial wrapper around `ElaborateDropsCtxt` that serves no apparent purpose.
1 parent dc62f07 commit 0b032f8

1 file changed

Lines changed: 24 additions & 36 deletions

File tree

‎compiler/rustc_mir_transform/src/elaborate_drops.rs‎

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -137,45 +137,35 @@ impl InitializationData<'_, '_> {
137137
}
138138
}
139139

140-
structElaborator<'a,'b,'tcx>{
141-
ctxt:&'amutElaborateDropsCtxt<'b,'tcx>,
142-
}
143-
144-
impl fmt::DebugforElaborator<'_,'_,'_>{
145-
fnfmt(&self,_f:&mut fmt::Formatter<'_>) -> fmt::Result{
146-
Ok(())
147-
}
148-
}
149-
150-
impl<'b,'tcx>DropElaborator<'b,'tcx>forElaborator<'_,'b,'tcx>{
140+
impl<'a,'tcx>DropElaborator<'a,'tcx>forElaborateDropsCtxt<'a,'tcx>{
151141
typePath = MovePathIndex;
152142

153143
fnpatch(&mutself) -> &mutMirPatch<'tcx>{
154-
&mutself.ctxt.patch
144+
&mutself.patch
155145
}
156146

157-
fnbody(&self) -> &'bBody<'tcx>{
158-
self.ctxt.body
147+
fnbody(&self) -> &'aBody<'tcx>{
148+
self.body
159149
}
160150

161151
fntcx(&self) -> TyCtxt<'tcx>{
162-
self.ctxt.tcx
152+
self.tcx
163153
}
164154

165155
fnparam_env(&self) -> ty::ParamEnv<'tcx>{
166-
self.ctxt.param_env()
156+
self.param_env()
167157
}
168158

169159
#[instrument(level = "debug", skip(self), ret)]
170160
fndrop_style(&self,path:Self::Path,mode:DropFlagMode) -> DropStyle{
171161
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),
173163
DropFlagMode::Deep => {
174164
letmut some_live = false;
175165
letmut some_dead = false;
176166
letmut 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);
179169
debug!("elaborate_drop: state({:?}) = {:?}", child,(live, dead));
180170
some_live |= live;
181171
some_dead |= dead;
@@ -195,25 +185,25 @@ impl<'b, 'tcx> DropElaborator<'b, 'tcx> for Elaborator<'_, 'b, 'tcx> {
195185
fnclear_drop_flag(&mutself,loc:Location,path:Self::Path,mode:DropFlagMode){
196186
match mode {
197187
DropFlagMode::Shallow => {
198-
self.ctxt.set_drop_flag(loc, path,DropFlagState::Absent);
188+
self.set_drop_flag(loc, path,DropFlagState::Absent);
199189
}
200190
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)
203193
});
204194
}
205195
}
206196
}
207197

208198
fnfield_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 {
210200
ProjectionElem::Field(idx, _) => idx == field,
211201
_ => false,
212202
})
213203
}
214204

215205
fnarray_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 {
217207
ProjectionElem::ConstantIndex{ offset, min_length, from_end } => {
218208
debug_assert!(size == min_length,"min_length should be exact for arrays");
219209
assert!(!from_end,"from_end should not be used for array element ConstantIndex");
@@ -224,20 +214,20 @@ impl<'b, 'tcx> DropElaborator<'b, 'tcx> for Elaborator<'_, 'b, 'tcx> {
224214
}
225215

226216
fnderef_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| {
228218
e == ProjectionElem::Deref
229219
})
230220
}
231221

232222
fndowncast_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 {
234224
ProjectionElem::Downcast(_, idx) => idx == variant,
235225
_ => false,
236226
})
237227
}
238228

239229
fnget_drop_flag(&mutself,path:Self::Path) -> Option<Operand<'tcx>>{
240-
self.ctxt.drop_flag(path).map(Operand::Copy)
230+
self.drop_flag(path).map(Operand::Copy)
241231
}
242232
}
243233

@@ -250,6 +240,12 @@ struct ElaborateDropsCtxt<'a, 'tcx> {
250240
patch:MirPatch<'tcx>,
251241
}
252242

243+
impl fmt::DebugforElaborateDropsCtxt<'_,'_>{
244+
fnfmt(&self,_f:&mut fmt::Formatter<'_>) -> fmt::Result{
245+
Ok(())
246+
}
247+
}
248+
253249
impl<'a,'tcx>ElaborateDropsCtxt<'a,'tcx>{
254250
fnmove_data(&self) -> &'aMoveData<'tcx>{
255251
&self.env.move_data
@@ -370,15 +366,7 @@ impl<'a, 'tcx> ElaborateDropsCtxt<'a, 'tcx> {
370366
}
371367
};
372368
self.init_data.seek_before(self.body.terminator_loc(bb));
373-
elaborate_drop(
374-
&mutElaborator{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)
382370
}
383371
LookupResult::Parent(None) => {}
384372
LookupResult::Parent(Some(_)) => {

0 commit comments

Comments
 (0)