]> git.lizzy.rs Git - rust.git/blob - tests/mir-opt/copy-prop/branch.rs
Auto merge of #107443 - cjgillot:generator-less-query, r=compiler-errors
[rust.git] / tests / mir-opt / copy-prop / branch.rs
1 //! Tests that we bail out when there are multiple assignments to the same local.
2 // unit-test: CopyProp
3 fn val() -> i32 {
4     1
5 }
6
7 fn cond() -> bool {
8     true
9 }
10
11 // EMIT_MIR branch.foo.CopyProp.diff
12 fn foo() -> i32 {
13     let x = val();
14
15     let y = if cond() {
16         x
17     } else {
18         val();
19         x
20     };
21
22     y
23 }
24
25 fn main() {
26     foo();
27 }