diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2025-07-02 22:09:46 +0000 |
|---|---|---|
| committer | Camille Gillot <gillot.camille@gmail.com> | 2025-09-07 13:55:01 +0000 |
| commit | 91241a1d255bde9d1bc3399c1c1f779bb17f1cfa (patch) | |
| tree | b560330aff4a678bc58be4cfc8b582c3345be081 | |
| parent | bea625f3275e3c897dc965ed97a1d19ef7831f01 (diff) | |
| download | rust-91241a1d255bde9d1bc3399c1c1f779bb17f1cfa.tar.gz rust-91241a1d255bde9d1bc3399c1c1f779bb17f1cfa.zip | |
Ensure indirect is first projection in try_as_place.
| -rw-r--r-- | compiler/rustc_mir_transform/src/gvn.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 5a13394543b..7f005accc65 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -1654,6 +1654,11 @@ impl<'tcx> VnState<'_, 'tcx> { let place = Place { local, projection: self.tcx.mk_place_elems(projection.as_slice()) }; return Some(place); + } else if projection.last() == Some(&PlaceElem::Deref) { + // `Deref` can only be the first projection in a place. + // If we are here, we failed to find a local, and we already have a `Deref`. + // Trying to add projections will only result in an ill-formed place. + return None; } else if let Value::Projection(pointer, proj) = *self.get(index) && (allow_complex_projection || proj.is_stable_offset()) && let Some(proj) = self.try_as_place_elem(self.ty(index), proj, loc) |
