about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-09-21 15:06:20 +0000
committerbors <bors@rust-lang.org>2020-09-21 15:06:20 +0000
commit4eff9b0b29a8898c839d46f3c66526710afed68a (patch)
tree293b62ed5a035e287e40e111ccf1d32bf18de682 /src/test
parente0bf356f9e5f6a8cca1eb656e900ffba79340fa1 (diff)
parent6417eb0cff24da1a6e026891c0714ef8f4f773bd (diff)
downloadrust-4eff9b0b29a8898c839d46f3c66526710afed68a.tar.gz
rust-4eff9b0b29a8898c839d46f3c66526710afed68a.zip
Auto merge of #77013 - RalfJung:rollup-84ut0xq, r=RalfJung
Rollup of 10 pull requests

Successful merges:

 - #76439 (Add error explanation for E0755)
 - #76521 (Fix segfault if pthread_getattr_np fails)
 - #76835 (make replace_prefix only take &str as arguments )
 - #76967 (Revert adding Atomic::from_mut.)
 - #76977 (Add a regression test for copy propagation miscompilation)
 - #76981 (liballoc bench use imported path Bencher)
 - #76983 (BTreeMap: extra testing & fixed comments)
 - #76996 (Fix typo in rustc_lexer docs)
 - #77009 (Dogfood total_cmp in the test crate)
 - #77012 (update Miri for another bugfix)

Failed merges:

 - #76489 (Add explanation for E0756)

r? `@ghost`
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/ffi_pure.stderr1
-rw-r--r--src/test/ui/mir/issue-76740-copy-propagation.rs30
2 files changed, 31 insertions, 0 deletions
diff --git a/src/test/ui/ffi_pure.stderr b/src/test/ui/ffi_pure.stderr
index 3a849c0bca7..bc911c85ddb 100644
--- a/src/test/ui/ffi_pure.stderr
+++ b/src/test/ui/ffi_pure.stderr
@@ -6,3 +6,4 @@ LL | #[ffi_pure]
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0755`.
diff --git a/src/test/ui/mir/issue-76740-copy-propagation.rs b/src/test/ui/mir/issue-76740-copy-propagation.rs
new file mode 100644
index 00000000000..e3283949b26
--- /dev/null
+++ b/src/test/ui/mir/issue-76740-copy-propagation.rs
@@ -0,0 +1,30 @@
+// Regression test for issue #76740.
+// run-fail FIXME: change to run-pass once #76899 lands
+// compile-flags: -Zmir-opt-level=3
+
+#[derive(Copy, Clone)]
+pub struct V([usize; 4]);
+
+impl V {
+    fn new() -> Self {
+        V([0; 4])
+    }
+
+    #[inline(never)]
+    fn check(mut self) {
+        assert_eq!(self.0[0], 0);
+        self.0[0] = 1;
+    }
+}
+
+fn main() {
+    let v = V::new();
+    let mut i = 0;
+    while i != 10 {
+        // Copy propagation incorrectly assumed that Operand::Move does not
+        // mutate the local, and used the same v for each V::check call,
+        // rather than a copy.
+        v.check();
+        i += 1;
+    }
+}