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

New attribute syntax incompatible with macro_rules attr matchers #13067

Closed
brson opened this issue Mar 22, 2014 · 2 comments
Closed

New attribute syntax incompatible with macro_rules attr matchers #13067

brson opened this issue Mar 22, 2014 · 2 comments

Comments

@brson
Copy link
Contributor

brson commented Mar 22, 2014

This is a problem in compile-fail/macro-inner-attributes.rs under the new attribute syntax. In macro_rules, an attr matcher matches #[foo], which leaves no way to match inner attributes. @alexcrichton suggests changing these to meta matchers that don't match the # or brackets. Nominating.

brson added a commit to brson/rust that referenced this issue Mar 22, 2014
This exposes issue rust-lang#13067, in which the new inner attribute syntax
is incompatible with macro_rules! `attr` matchers. I had to 'ignore'
compile-fail/macro-inner-attributes.
@alexcrichton
Copy link
Member

We decided in today's meeting to add a new meta matcher for macros, and to remove the attr matcher. I believe you should still be able to write macros that look like:

macro_rules! foo( (#[$foo:meta]) => ( fn foo() { #![$foo] } ) )

@brson
Copy link
Contributor Author

brson commented Mar 26, 2014

It would be very nice to get the attribute syntax conversion done for 0.10, but this is blocking, and I don't think I will get to it this week.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Mar 28, 2014
This removes the `attr` matcher and adds a `meta` matcher. The previous `attr`
matcher is now ambiguous because it doesn't disambiguate whether it means inner
attribute or outer attribute.

The new behavior can still be achieved by taking an argument of the form
`#[$foo:meta]` (the brackets are part of the macro pattern).

Closes rust-lang#13067
bors added a commit that referenced this issue Mar 28, 2014
This is the rebasing of #13068 with a fix for #13067 as the first commit.
bors added a commit that referenced this issue Mar 29, 2014
This is the rebasing of #13068 with a fix for #13067 as the first commit.
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 11, 2024
Misc refactorings part 3

And some more changes. Same general idea of checking the HIR tree first when linting.

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants