2013-03-01 21:57:05 -06:00
|
|
|
struct Foo {
|
2014-05-22 18:57:53 -05:00
|
|
|
t: String
|
2013-03-01 21:57:05 -06:00
|
|
|
}
|
|
|
|
|
2013-11-11 13:29:15 -06:00
|
|
|
fn cond() -> bool { true }
|
|
|
|
|
2015-01-03 09:45:00 -06:00
|
|
|
fn foo<F>(_: F) where F: FnOnce() {}
|
2013-11-11 13:29:15 -06:00
|
|
|
|
2011-06-10 16:34:01 -05:00
|
|
|
fn main() {
|
2019-08-21 07:13:13 -05:00
|
|
|
let pth = break; //~ ERROR: `break` outside of a loop
|
|
|
|
if cond() { continue } //~ ERROR: `continue` outside of a loop
|
2011-06-10 16:34:01 -05:00
|
|
|
|
2013-11-11 13:29:15 -06:00
|
|
|
while cond() {
|
|
|
|
if cond() { break }
|
|
|
|
if cond() { continue }
|
2013-11-21 19:23:21 -06:00
|
|
|
foo(|| {
|
2013-11-11 13:29:15 -06:00
|
|
|
if cond() { break } //~ ERROR: `break` inside of a closure
|
|
|
|
if cond() { continue } //~ ERROR: `continue` inside of a closure
|
2013-11-21 19:23:21 -06:00
|
|
|
})
|
2013-11-11 13:29:15 -06:00
|
|
|
}
|
2011-06-10 16:34:01 -05:00
|
|
|
|
2013-11-11 13:29:15 -06:00
|
|
|
let rs: Foo = Foo{t: pth};
|
2014-04-04 18:05:31 -05:00
|
|
|
|
2019-08-21 07:13:13 -05:00
|
|
|
let unconstrained = break; //~ ERROR: `break` outside of a loop
|
2019-10-17 15:16:24 -05:00
|
|
|
|
|
|
|
// This used to ICE because `target_id` passed to `check_expr_break` would be the closure and
|
|
|
|
// not the `loop`, which failed in the call to `find_breakable`. (#65383)
|
|
|
|
'lab: loop {
|
|
|
|
|| {
|
2020-06-25 09:16:38 -05:00
|
|
|
break 'lab;
|
|
|
|
//~^ ERROR use of unreachable label `'lab`
|
|
|
|
//~| ERROR `break` inside of a closure
|
2019-10-17 15:16:24 -05:00
|
|
|
};
|
|
|
|
}
|
2011-08-19 17:16:48 -05:00
|
|
|
}
|