2021-07-10 09:38:55 -05:00
|
|
|
#![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; }; }
|
2021-07-10 09:38:55 -05:00
|
|
|
//~^ 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() {
|
2021-07-10 09:38:55 -05:00
|
|
|
// 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
|
|
|
}
|