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
This commit is contained in:
commit
34ea55908e
3 changed files with 28 additions and 29 deletions
15
src/test/ui/consts/const-eval/issue-64970.rs
Normal file
15
src/test/ui/consts/const-eval/issue-64970.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// run-pass
|
||||
|
||||
fn main() {
|
||||
foo(10);
|
||||
}
|
||||
|
||||
fn foo(mut n: i32) {
|
||||
if false {
|
||||
n = 0i32;
|
||||
}
|
||||
|
||||
if n > 0i32 {
|
||||
1i32 / n;
|
||||
}
|
||||
}
|
||||
8
src/test/ui/consts/const-eval/issue-64970.stderr
Normal file
8
src/test/ui/consts/const-eval/issue-64970.stderr
Normal file
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue