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

Open
xfix opened this issue Oct 10, 2019 · 1 comment

Comments

@xfix
Copy link
Contributor

@xfix xfix 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.

@xfix xfix changed the title Label shadowing causes a warning that cannot be avoided Label shadowing causes a warning that cannot be allowed Oct 10, 2019
@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum commented Oct 12, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.