Closed
Description
It was necessary to generate such code, everything works, but I get warning. The question is how to remove this warning if the “rust” does not give such an opportunity, or is there an error here?
Executable code:
macro_rules! gen_code {
[$l:lifetime: $b:block, $b2: block $(,)?] => {
$l: loop {
$b
break $l;
}
$l: loop {
$b2
break $l;
}
};
}
fn main() {
gen_code! {
'root:
{
println!("Block1");
},
{
println!("Block2");
},
}
}
Output:
Compiling playground v0.0.1 (/playground)
warning: label name `'root` shadows a label name that is already in scope
--> src/main.rs:17:9
|
17 | 'root:
| ^^^^^
| |
| first declared here
| lifetime 'root already in scope
Finished dev [unoptimized + debuginfo] target(s) in 0.39s
Running `target/debug/playground`
Standard Output
Block1
Block2
Version:
rustc 1.43.0-nightly (58b834344 2020-02-05)