about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-10-02 18:24:43 +0200
committerGitHub <noreply@github.com>2019-10-02 18:24:43 +0200
commit34ea55908e36e2b83d5ccdf34fa81aed95ecc44b (patch)
tree2880583b0b61c437614fd545370b762cabbe90bd /src/test
parent028ffd136659eabdc1fd4c1d2e2d5f8043440cff (diff)
parent3a8932d9b0d12a67c9b92e0370de708a089d50b4 (diff)
downloadrust-34ea55908e36e2b83d5ccdf34fa81aed95ecc44b.tar.gz
rust-34ea55908e36e2b83d5ccdf34fa81aed95ecc44b.zip
Rollup merge of #64991 - wesleywiser:fix_too_eager_const_prop, r=oli-obk
[const-prop] Correctly handle locals that can't be propagated

`const_prop()` now handles writing the Rvalue into the Place in the
stack frame for us. So if we're not supposed to propagate that value,
we need to clear it.

r? @oli-obk

Fixes #64970
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/consts/const-eval/issue-64970.rs15
-rw-r--r--src/test/ui/consts/const-eval/issue-64970.stderr8
2 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/consts/const-eval/issue-64970.rs b/src/test/ui/consts/const-eval/issue-64970.rs
new file mode 100644
index 00000000000..ede5081c8a5
--- /dev/null
+++ b/src/test/ui/consts/const-eval/issue-64970.rs
@@ -0,0 +1,15 @@
+// run-pass
+
+fn main() {
+    foo(10);
+}
+
+fn foo(mut n: i32) {
+    if false {
+        n = 0i32;
+    }
+
+    if n > 0i32 {
+        1i32 / n;
+    }
+}
diff --git a/src/test/ui/consts/const-eval/issue-64970.stderr b/src/test/ui/consts/const-eval/issue-64970.stderr
new file mode 100644
index 00000000000..2c44b68cbd1
--- /dev/null
+++ b/src/test/ui/consts/const-eval/issue-64970.stderr
@@ -0,0 +1,8 @@
+warning: unused arithmetic operation that must be used
+  --> $DIR/issue-64970.rs:13:9
+   |
+LL |         1i32 / n;
+   |         ^^^^^^^^
+   |
+   = note: `#[warn(unused_must_use)]` on by default
+