summary refs log tree commit diff
path: root/src/test/mir-opt/const_prop_miscompile.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-07-26 16:09:42 +0000
committerbors <bors@rust-lang.org>2020-07-26 16:09:42 +0000
commitc367798cfd3817ca6ae908ce675d1d99242af148 (patch)
tree3c697026c11f13b35d61371c36921e6b3d1de1ca /src/test/mir-opt/const_prop_miscompile.rs
parent14485ee1257703df51313efe39daf35e886e4dac (diff)
parent41895ca93f3722adf5855089442de3abc94458f0 (diff)
downloadrust-1.45.1.tar.gz
rust-1.45.1.zip
Auto merge of #74746 - wesleywiser:stable_backport_73669, r=Mark-Simulacrum 1.45.1
Stable backport of #73613

This is the backport of #73613 to stable.

r? @ghost

cc @Mark-Simulacrum

In addition the tests added in the original PR passing, I've also confirmed that the test case in #74739 works correctly.
Diffstat (limited to 'src/test/mir-opt/const_prop_miscompile.rs')
-rw-r--r--src/test/mir-opt/const_prop_miscompile.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/mir-opt/const_prop_miscompile.rs b/src/test/mir-opt/const_prop_miscompile.rs
new file mode 100644
index 00000000000..043b22870f4
--- /dev/null
+++ b/src/test/mir-opt/const_prop_miscompile.rs
@@ -0,0 +1,22 @@
+#![feature(raw_ref_op)]
+
+// EMIT_MIR rustc.foo.ConstProp.diff
+fn foo() {
+    let mut u = (1,);
+    *&mut u.0 = 5;
+    let y = { u.0 } == 5;
+}
+
+// EMIT_MIR rustc.bar.ConstProp.diff
+fn bar() {
+    let mut v = (1,);
+    unsafe {
+        *&raw mut v.0 = 5;
+    }
+    let y = { v.0 } == 5;
+}
+
+fn main() {
+    foo();
+    bar();
+}