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

Label shadowing causes a warning that cannot be allowed #65269

Closed
KamilaBorowska opened this issue Oct 10, 2019 · 2 comments
Closed

Label shadowing causes a warning that cannot be allowed #65269

KamilaBorowska opened this issue Oct 10, 2019 · 2 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@KamilaBorowska
Copy link
Contributor

KamilaBorowska commented Oct 10, 2019

macro_rules! m {
    ($a:expr) => {
        'label: for _ in 0..1 {
            $a;
        }
    }
}

fn main() {
    m!(m!(1));
}

causes the following warning:

warning: label name `'label` shadows a label name that is already in scope
  --> src/main.rs:3:9
   |
3  |         'label: for _ in 0..1 {
   |         ^^^^^^
   |         |
   |         first declared here
   |         lifetime 'label already in scope
...
10 |     m!(m!(1));
   |        ----- in this macro invocation

There is no way to allow the warning.

@KamilaBorowska KamilaBorowska changed the title Label shadowing causes a warning that cannot be avoided Label shadowing causes a warning that cannot be allowed Oct 10, 2019
@jonas-schievink jonas-schievink added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 10, 2019
@Mark-Simulacrum
Copy link
Member

This

// shadowing involving a label is only a warning, due to issues with
// labels and lifetimes not being macro-hygienic.
tcx.sess.struct_span_warn(
shadower.span,
&format!(
"{} name `{}` shadows a \
{} name that is already in scope",
shadower.kind.desc(),
name,
orig.kind.desc()
),
)
piece of code should be converted to emitting a lint versus a warning, I think

@KamilaBorowska
Copy link
Contributor Author

Duplicate of #31745, closing.

@KamilaBorowska KamilaBorowska closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. 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

No branches or pull requests

3 participants