Skip to content

Commit 62766e3

Browse files
committed
Ensure indirect is first projection in try_as_place.
1 parent 00983c4 commit 62766e3

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
@@ -1748,6 +1748,11 @@ impl<'tcx> VnState<'_, '_, 'tcx> {
17481748
let place =
17491749
Place { local, projection: self.tcx.mk_place_elems(projection.as_slice()) };
17501750
return Some(place);
1751+
} else if projection.last() == Some(&PlaceElem::Deref) {
1752+
// `Deref` can only be the first projection in a place.
1753+
// If we are here, we failed to find a local, and we already have a `Deref`.
1754+
// Trying to add projections will only result in an ill-formed place.
1755+
return None;
17511756
} else if let Value::Projection(pointer, proj) = self.get(index)
17521757
&& (allow_complex_projection || proj.is_stable_offset())
17531758
&& let Some(proj) = self.try_as_place_elem(self.ty(index), proj, loc)

0 commit comments

Comments
 (0)