Skip to content

Commit 73264f2

Browse files
committed
Restrict drop to empty projections.
1 parent 97f88f5 commit 73264f2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_mir_transform/src/deduce_param_attrs.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ impl<'tcx> Visitor<'tcx> for DeduceReadOnly {
4747
// Dereference is not a mutation.
4848
_ if place.is_indirect_first_projection() => {}
4949
// This is a `Drop`. It could disappear at monomorphization, so mark it specially.
50-
PlaceContext::MutatingUse(MutatingUseContext::Drop) => {
50+
PlaceContext::MutatingUse(MutatingUseContext::Drop)
51+
// Projection changes the place's type, so `needs_drop(local.ty)` is not
52+
// `needs_drop(place.ty)`.
53+
if place.projection.is_empty() => {
5154
self.read_only[param_index] |= DeducedReadOnlyParam::IF_NO_DROP;
5255
}
5356
// This is a mutation, so mark it as such.

0 commit comments

Comments
 (0)