]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-24267-flow-exit.rs
Auto merge of #107663 - matthiaskrgr:107423-point-at-EOF-code, r=compiler-errors
[rust.git] / tests / ui / borrowck / issue-24267-flow-exit.rs
1 // Ensure that we reject code when a nonlocal exit (`break`,
2 // `continue`) causes us to pop over a needed assignment.
3
4 pub fn main() {
5     foo1();
6     foo2();
7 }
8
9 pub fn foo1() {
10     let x: i32;
11     loop { x = break; }
12     println!("{}", x); //~ ERROR E0381
13 }
14
15 pub fn foo2() {
16     let x: i32;
17     for _ in 0..10 { x = continue; }
18     println!("{}", x); //~ ERROR E0381
19 }