]> git.lizzy.rs Git - rust.git/blob - tests/ui/for-loop-while/loop-no-reinit-needed-post-bot.rs
Rollup merge of #106144 - tgross35:patch-1, r=Mark-Simulacrum
[rust.git] / tests / ui / for-loop-while / loop-no-reinit-needed-post-bot.rs
1 // run-pass
2 // pretty-expanded FIXME #23616
3
4 struct S;
5 // Ensure S is moved, not copied, on assignment.
6 impl Drop for S { fn drop(&mut self) { } }
7
8 // user-defined function "returning" bottom (i.e., no return at all).
9 fn my_panic() -> ! { loop {} }
10
11 pub fn step(f: bool) {
12     let mut g = S;
13     let mut i = 0;
14     loop
15     {
16         if i > 10 { break; } else { i += 1; }
17
18         let _g = g;
19
20         if f {
21             // re-initialize g, but only before restarting loop.
22             g = S;
23             continue;
24         }
25
26         my_panic();
27
28         // we never get here, so we do not need to re-initialize g.
29     }
30 }
31
32 pub fn main() {
33     step(true);
34 }