Skip to content

Commit 5fd64dd

Browse files
committed
Simplified logic and corrected shallow to deep.
1 parent e7f328e commit 5fd64dd

File tree

1 file changed

+11
-29
lines changed
  • src/librustc_mir/borrow_check

1 file changed

+11
-29
lines changed

src/librustc_mir/borrow_check/mod.rs

+11-29
Original file line numberDiff line numberDiff line change
@@ -727,35 +727,17 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
727727
// See #47703.
728728
ty::TyAdt(def, substs) if def.is_struct() && !def.has_dtor(self.tcx) => {
729729
for (index, field) in def.all_fields().enumerate() {
730-
let field_ty = field.ty(self.tcx, substs);
731-
let proj = Projection {
732-
base: drop_place.clone(),
733-
elem: ProjectionElem::Field(Field::new(index), field_ty),
734-
};
735-
let place = Place::Projection(Box::new(proj));
736-
737-
match field_ty.sty {
738-
// It may be the case that this issue occurs with a struct within a
739-
// struct, so we recurse to handle that.
740-
ty::TyAdt(def, _) if def.is_struct() && !def.has_dtor(self.tcx) => {
741-
self.visit_terminator_drop(
742-
loc,
743-
term,
744-
flow_state,
745-
&place,
746-
span,
747-
);
748-
},
749-
_ => {
750-
self.access_place(
751-
ContextKind::Drop.new(loc),
752-
(&place, span),
753-
(Shallow(None), Write(WriteKind::StorageDeadOrDrop)),
754-
LocalMutationIsAllowed::Yes,
755-
flow_state,
756-
);
757-
},
758-
}
730+
let place = drop_place.clone();
731+
let place = place.field(Field::new(index), field.ty(self.tcx, substs));
732+
let place = place.deref();
733+
734+
self.visit_terminator_drop(
735+
loc,
736+
term,
737+
flow_state,
738+
&place,
739+
span,
740+
);
759741
}
760742
},
761743
_ => {

0 commit comments

Comments
 (0)