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

unhygienic named labels allowed in macros #9171

Closed
metajack opened this issue Sep 13, 2013 · 6 comments
Closed

unhygienic named labels allowed in macros #9171

metajack opened this issue Sep 13, 2013 · 6 comments
Labels
A-syntaxext Area: Syntax extensions

Comments

@metajack
Copy link
Contributor

Hygiene currently prevents capturing variables but does not prevent you from capturing named labels.

For example:

fn main() {
    macro_rules! breakme(
        ($value: expr) => {
            break 'foo;
        }
    )
    'foo: loop { 
        breakme!("foo");
    }
}

Note, this currently causes a bus error in rustc, but probably otherwise works, and used to work before let hygiene was added.

@metajack
Copy link
Contributor Author

cc @jbclements

@jbclements
Copy link
Contributor

@metajack as I said on felix's bug, I can't reproduce this on 248765a, my last merge... maybe the next merge, cabba6b, the merge of #9136 ?

@alexcrichton
Copy link
Member

This code compiles on today's master, and it sounds like it shouldn't.

@jbclements
Copy link
Contributor

No, I think that's fine. We've never made any attempt to impose hygiene on labels. I suppose it depends on what you mean by "shouldn't." I agree that it might be nice to implement hygiene for labels ...

@edwardw
Copy link
Contributor

edwardw commented Mar 9, 2014

After #12338, rustc now gives an error:

fn main() {
    macro_rules! breakme(
        ($value: expr) => {
            break 'foo;    // error: use of undeclared label `foo`
        }
    )
    'foo: loop { 
        breakme!("foo");
    }
}

So this probably could be closed.

@alexcrichton
Copy link
Member

Hurray! Thanks @edwardw!

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 18, 2022
Update highlight.js

changelog: none

With [highlight.js v11.6.0](https://github.com/highlightjs/highlight.js/releases/tag/11.6.0), the lint list can finally update from `9.5.0`. No more EOL warning in console! 😄

I also made it switch to the `github-dark` theme when using `coal`, instead of just always using the normal github light theme.

r? `@xFrednet`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions
Projects
None yet
Development

No branches or pull requests

4 participants