2013-03-02 12:57:05 +09:00
|
|
|
struct Foo {
|
2014-05-22 16:57:53 -07:00
|
|
|
t: String
|
2013-03-02 12:57:05 +09:00
|
|
|
}
|
|
|
|
|
2013-11-11 11:29:15 -08:00
|
|
|
fn cond() -> bool { true }
|
|
|
|
|
2015-01-03 10:45:00 -05:00
|
|
|
fn foo<F>(_: F) where F: FnOnce() {}
|
2013-11-11 11:29:15 -08:00
|
|
|
|
2011-06-10 14:34:01 -07:00
|
|
|
fn main() {
|
2019-08-21 15:13:13 +03:00
|
|
|
let pth = break; //~ ERROR: `break` outside of a loop
|
|
|
|
if cond() { continue } //~ ERROR: `continue` outside of a loop
|
2011-06-10 14:34:01 -07:00
|
|
|
|
2013-11-11 11:29:15 -08:00
|
|
|
while cond() {
|
|
|
|
if cond() { break }
|
|
|
|
if cond() { continue }
|
2013-11-21 17:23:21 -08:00
|
|
|
foo(|| {
|
2013-11-11 11:29:15 -08:00
|
|
|
if cond() { break } //~ ERROR: `break` inside of a closure
|
|
|
|
if cond() { continue } //~ ERROR: `continue` inside of a closure
|
2013-11-21 17:23:21 -08:00
|
|
|
})
|
2013-11-11 11:29:15 -08:00
|
|
|
}
|
2011-06-10 14:34:01 -07:00
|
|
|
|
2013-11-11 11:29:15 -08:00
|
|
|
let rs: Foo = Foo{t: pth};
|
2014-04-05 10:05:31 +11:00
|
|
|
|
2019-08-21 15:13:13 +03:00
|
|
|
let unconstrained = break; //~ ERROR: `break` outside of a loop
|
2019-10-17 13:16:24 -07: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 15:16:38 +01:00
|
|
|
break 'lab;
|
|
|
|
//~^ ERROR use of unreachable label `'lab`
|
|
|
|
//~| ERROR `break` inside of a closure
|
2019-10-17 13:16:24 -07:00
|
|
|
};
|
|
|
|
}
|
2011-08-19 15:16:48 -07:00
|
|
|
}
|