rust/tests/ui/for-loop-while/label_break_value_invalid.rs
2023-01-11 09:32:08 +00:00

36 lines
724 B
Rust

#![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
}
};
}
let x: u8 = mac3!('b: {
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);
}