Skip to content

Commit 91241a1

Browse files
committed
Ensure indirect is first projection in try_as_place.
1 parent bea625f commit 91241a1

File tree

1 file changed

+5
-0
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+5
-0
lines changed

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,11 @@ impl<'tcx> VnState<'_, 'tcx> {
16541654
let place =
16551655
Place { local, projection: self.tcx.mk_place_elems(projection.as_slice()) };
16561656
return Some(place);
1657+
} else if projection.last() == Some(&PlaceElem::Deref) {
1658+
// `Deref` can only be the first projection in a place.
1659+
// If we are here, we failed to find a local, and we already have a `Deref`.
1660+
// Trying to add projections will only result in an ill-formed place.
1661+
return None;
16571662
} else if let Value::Projection(pointer, proj) = *self.get(index)
16581663
&& (allow_complex_projection || proj.is_stable_offset())
16591664
&& let Some(proj) = self.try_as_place_elem(self.ty(index), proj, loc)

0 commit comments

Comments
 (0)