Skip to content

Commit c169ed7

Browse files
committed
Ensure indirect is first projection in try_as_place.
1 parent 489a7f9 commit c169ed7

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
@@ -1716,6 +1716,11 @@ impl<'tcx> VnState<'_, '_, 'tcx> {
17161716
let place =
17171717
Place { local, projection: self.tcx.mk_place_elems(projection.as_slice()) };
17181718
return Some(place);
1719+
} else if projection.last() == Some(&PlaceElem::Deref) {
1720+
// `Deref` can only be the first projection in a place.
1721+
// If we are here, we failed to find a local, and we already have a `Deref`.
1722+
// Trying to add projections will only result in an ill-formed place.
1723+
return None;
17191724
} else if let Value::Projection(pointer, proj) = self.get(index)
17201725
&& (allow_complex_projection || proj.is_stable_offset())
17211726
&& let Some(proj) = self.try_as_place_elem(self.ty(index), proj, loc)

0 commit comments

Comments
 (0)