Skip to content
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

Unexpected shadow label warning #81799

Closed
ghost opened this issue Feb 5, 2021 · 5 comments
Closed

Unexpected shadow label warning #81799

ghost opened this issue Feb 5, 2021 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@ghost
Copy link

ghost commented Feb 5, 2021

This code produces the warning:

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

Playground link.

@ehuss
Copy link
Contributor

ehuss commented Feb 5, 2021

I believe this is intended behavior, see #21633 and https://internals.rust-lang.org/t/psa-rejecting-duplicate-loop-labels/1833.

I think the warning should be converted to a future-compatible lint if the lang team really wants to keep it.

@ghost
Copy link
Author

ghost commented Feb 5, 2021

The label isn't in the same scope and there isn't a way to disable/#[allow(...)] this warning. Plus this is accepted by the compiler.

@ehuss
Copy link
Contributor

ehuss commented Feb 5, 2021

I think the intent is to make the entire function one scope, instead of using block scopes. You are correct that there isn't a way to allow it, and that should be fixed (this warning was added pre-1.0, a lot has changed since then).

@Nicholas-Baron
Copy link
Contributor

@rustbot label: +A-diagnostics +A-lint.

@rustbot rustbot added A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Feb 14, 2021
@ehuss
Copy link
Contributor

ehuss commented Mar 13, 2021

Closing as a duplicate of #31745.

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 A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

3 participants