Skip to content

Incorrect label shadow warning #88225

Closed
Closed
@WiSaGaN

Description

@WiSaGaN

I tried this code:

fn main() {
    if true {
        'l : loop {
            break 'l;
        }
    } else {
        'l : loop {
            break 'l;
        }
    }
}

I expected to see this happen: no warning regarding to label

Instead, this happened: got warning about label shadowing

warning: label name `'l` shadows a label name that is already in scope
 --> src/main.rs:7:9
  |
3 |         'l : loop {
  |         -- first declared here
...
7 |         'l : loop {
  |         ^^ label `'l` already in scope

version

Build using the Nightly version: 1.56.0-nightly

(2021-08-21 d3e2578c31688619ddc0)

playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions