Skip to content

Label-shadowing warning incorrectly calls a label 'lifetime' #79610

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
nico-abram opened this issue Dec 1, 2020 · 0 comments · Fixed by #79620
Closed

Label-shadowing warning incorrectly calls a label 'lifetime' #79610

nico-abram opened this issue Dec 1, 2020 · 0 comments · Fixed by #79620
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nico-abram
Copy link
Contributor

When compiling the following code:

fn main() {
    'a: for _ in 0..1 { break 'a; }
    'a: for _ in 0..1 { break 'a; }
}

rust emits the following warning:

warning: label name `'a` shadows a label name that is already in scope
 --> src/main.rs:3:5
  |
2 |     'a: for _ in 0..1 { break 'a; }
  |     -- first declared here
3 |     'a: for _ in 0..1 { break 'a; }
  |     ^^ lifetime 'a already in scope

I tried nightly in the playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=eda5af652ad2b13204432834e1b67f8e and got the same output

lifetime 'a already in scope seems wrong, since 'a is not a lifetime, but a label

@nico-abram nico-abram added the C-bug Category: This is a bug. label Dec 1, 2020
@jonas-schievink jonas-schievink added the A-diagnostics Area: Messages for errors, warnings, and lints label Dec 1, 2020
@JohnTitor JohnTitor added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 2, 2020
@bors bors closed this as completed in 5be3f9f Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants