about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-11-27 15:43:56 +0000
committerbors <bors@rust-lang.org>2024-11-27 15:43:56 +0000
commit6b6a867ae9eac4e78d041ac4ee84be1072a48cf7 (patch)
tree29db05c7f6d4c448b4eae77166e355233e32bed6 /compiler/rustc_mir_transform
parentc322cd5c5ac13b5ef16a487c889f8c148d8e3841 (diff)
parent906f66fb4c22daa8a6f97e5c048e9f6ab3fd9051 (diff)
downloadrust-6b6a867ae9eac4e78d041ac4ee84be1072a48cf7.tar.gz
rust-6b6a867ae9eac4e78d041ac4ee84be1072a48cf7.zip
Auto merge of #133474 - RalfJung:gvn-miscompile, r=compiler-errors
Do not unify dereferences of shared borrows in GVN

Repost of https://github.com/rust-lang/rust/pull/132461, the last commit applies my suggestions.

Fixes https://github.com/rust-lang/rust/issues/130853
Diffstat (limited to 'compiler/rustc_mir_transform')
-rw-r--r--compiler/rustc_mir_transform/src/gvn.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs
index 976f4a8e919..d5a813ec8ec 100644
--- a/compiler/rustc_mir_transform/src/gvn.rs
+++ b/compiler/rustc_mir_transform/src/gvn.rs
@@ -638,7 +638,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
         let proj = match proj {
             ProjectionElem::Deref => {
                 let ty = place.ty(self.local_decls, self.tcx).ty;
-                if let Some(Mutability::Not) = ty.ref_mutability()
+                // unsound: https://github.com/rust-lang/rust/issues/130853
+                if self.tcx.sess.opts.unstable_opts.unsound_mir_opts
+                    && let Some(Mutability::Not) = ty.ref_mutability()
                     && let Some(pointee_ty) = ty.builtin_deref(true)
                     && pointee_ty.is_freeze(self.tcx, self.typing_env())
                 {