Skip to content

The ability to remove the warning label name T shadows a label name that is already in scope #70496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
denisandroid opened this issue Mar 28, 2020 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@denisandroid
Copy link

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

Play: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=28fa5504d1c601d272e5cef0f2b66cbc

Version:

rustc 1.43.0-nightly (58b834344 2020-02-05)
@denisandroid denisandroid added the C-bug Category: This is a bug. label Mar 28, 2020
@jonas-schievink
Copy link
Contributor

duplicate of #65269

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants