rust/tests/ui/parser/lifetime_starts_expressions.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.0 KiB
Rust
Raw Normal View History

#![allow(unused, dead_code)]
2018-04-23 04:18:04 -05:00
fn foo() -> u32 {
return 'label: loop { break 'label 42; };
}
fn bar() -> u32 {
loop { break 'label: loop { break 'label 42; }; }
//~^ ERROR: parentheses are required around this expression to avoid confusion
//~| HELP: wrap the expression in parentheses
}
fn baz() -> u32 {
'label: loop {
break 'label
//~^ WARNING: this labeled break expression is easy to confuse with an unlabeled break
loop { break 42; };
//~^ HELP: wrap this expression in parentheses
};
'label2: loop {
break 'label2 'inner: loop { break 42; };
// no warnings or errors here
}
2018-04-23 04:18:04 -05:00
}
pub fn main() {
// Regression test for issue #86948, as resolved in #87026:
let a = 'first_loop: loop {
break 'first_loop 1;
};
let b = loop {
break 'inner_loop: loop {
//~^ ERROR: parentheses are required around this expression to avoid confusion
//~| HELP: wrap the expression in parentheses
break 'inner_loop 1;
};
};
2018-04-23 04:18:04 -05:00
}