Auto merge of #38989 - arielb1:constant-mir-overflow2, r=eddyb

fix function arguments in constant promotion

we can't create the target block until *after* we promote the arguments - otherwise the arguments will be promoted into the target block. oops.

Fixes #38985.

This is a regression introduced in the beta-nominated #38833, so beta-nominating this one too (sorry @brson).

r? @eddyb
This commit is contained in:
bors 2017-01-11 15:45:28 +00:00
commit 513d942a7e
2 changed files with 22 additions and 13 deletions

View file

@ -14,7 +14,14 @@ const fn foo() -> i64 {
3
}
const fn bar(x: i64) -> i64 {
x*2
}
fn main() {
let val = &(foo() % 2);
assert_eq!(*val, 1);
let val2 = &(bar(1+1) % 3);
assert_eq!(*val2, 1);
}