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