]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-52713-bug.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / issue-52713-bug.rs
1 // Regression test for a bug in #52713: this was an optimization for
2 // computing liveness that wound up accidentally causing the program
3 // below to be accepted.
4
5 fn foo<'a>(x: &'a mut u32) -> u32 {
6     let mut x = 22;
7     let y = &x;
8     if false {
9         return x;
10     }
11
12     x += 1; //~ ERROR
13     println!("{}", y);
14     return 0;
15 }
16
17 fn main() { }