]>
Commit | Line | Data |
---|---|---|
223e47cc | 1 | struct Foo { |
1a4d82fc | 2 | t: String |
223e47cc LB |
3 | } |
4 | ||
1a4d82fc JJ |
5 | fn cond() -> bool { true } |
6 | ||
7 | fn foo<F>(_: F) where F: FnOnce() {} | |
8 | ||
223e47cc | 9 | fn main() { |
e1599b0c XL |
10 | let pth = break; //~ ERROR: `break` outside of a loop |
11 | if cond() { continue } //~ ERROR: `continue` outside of a loop | |
1a4d82fc JJ |
12 | |
13 | while cond() { | |
14 | if cond() { break } | |
15 | if cond() { continue } | |
16 | foo(|| { | |
17 | if cond() { break } //~ ERROR: `break` inside of a closure | |
18 | if cond() { continue } //~ ERROR: `continue` inside of a closure | |
19 | }) | |
20 | } | |
223e47cc LB |
21 | |
22 | let rs: Foo = Foo{t: pth}; | |
23 | ||
e1599b0c XL |
24 | let unconstrained = break; //~ ERROR: `break` outside of a loop |
25 | ||
26 | // This used to ICE because `target_id` passed to `check_expr_break` would be the closure and | |
27 | // not the `loop`, which failed in the call to `find_breakable`. (#65383) | |
28 | 'lab: loop { | |
29 | || { | |
f035d41b XL |
30 | break 'lab; |
31 | //~^ ERROR use of unreachable label `'lab` | |
32 | //~| ERROR `break` inside of a closure | |
e1599b0c XL |
33 | }; |
34 | } | |
223e47cc | 35 | } |