Skip to content

Using same label name in seemingly non-shadowing context generates warning #48764

Closed
@milesand

Description

@milesand

The following code:

fn main() {
    'a: loop {break;}
    'a: loop {break;}
}

generates the following warning:

warning: label name `'a` shadows a label name that is already in scope
 --> file_name.rs:3:5
  |
2 |     'a: loop {break;}
  |     -- first declared here
3 |     'a: loop {break;}
  |     ^^ lifetime 'a already in scope

As it is impossible to meaningfully use (as in break 'a) the 'a of the first loop from the second loop, the warning seems rather redundant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions