rust/tests/ui/for-loop-while/label_break_value_invalid.rs

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

36 lines
724 B
Rust
Raw Normal View History

2022-05-03 14:07:36 -05:00
#![crate_type = "lib"]
fn lbv_macro_test_hygiene_respected() {
macro_rules! mac2 {
($val:expr) => {
break 'a $val; //~ ERROR undeclared label `'a` [E0426]
};
}
let x: u8 = 'a: {
'b: {
if true {
mac2!(2);
}
};
0
};
assert_eq!(x, 2);
macro_rules! mac3 {
($val:expr) => {
'a: {
$val
}
};
}
2022-05-05 13:49:48 -05:00
let x: u8 = mac3!('b: {
2022-05-03 14:07:36 -05:00
if true {
break 'a 3; //~ ERROR undeclared label `'a` [E0426]
}
0
});
assert_eq!(x, 3);
let x: u8 = mac3!(break 'a 4); //~ ERROR undeclared label `'a` [E0426]
assert_eq!(x, 4);
}