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

Resolve attributes during name resolution #7049

Closed
wants to merge 3 commits into from
Closed

Resolve attributes during name resolution #7049

wants to merge 3 commits into from

Conversation

jonas-schievink
Copy link
Contributor

@jonas-schievink jonas-schievink commented Dec 27, 2020

Another step required to support procedural attribute macros. This will emit diagnostics when attributes can't be resolved to either a built-in attribute, or to something in macro namespace.

Procedural attribute macros refuse to expand, because they aren't yet fully implemented. Instead, they always get the unresolved-proc-macro diagnostic to let the user know.

Note that we don't yet ignore items with unresolved attributes on them. That's the next step required to support attribute macros.

Notes for users: This will result in false positive diagnostics when attributes are used that are consumed by procedural macros. The diagnostic can be disabled by adding "unresolved-attribute" to the rust-analyzer.diagnostics.disabled setting.

We need to do this, since they're not supported correctly. If we don't,
they create infinitely more files to process during nameres, which
makes r-a hang and run out of memory.
@flodiebold
Copy link
Member

We should make a note about this in the next changelog to prevent at least a few of the inevitable bug reports 😬

@jonas-schievink
Copy link
Contributor Author

Yeah, good idea. I've added a note to the PR description too.

@matklad
Copy link
Member

matklad commented Jan 10, 2021

Procedural attribute macros refuse to expand, because they aren't yet fully implemented. Instead, they always get the unresolved-proc-macro diagnostic to let the user know.

Hm, this feels less than ideal.... Perhaps we should make this sub-diagnostic experemental?

@matklad
Copy link
Member

matklad commented Jan 10, 2021

other than that, lgtm! (maybe only add .iter method to Attrs?)

@jonas-schievink
Copy link
Contributor Author

Hm, this feels less than ideal.... Perhaps we should make this sub-diagnostic experemental?

Yeah I can do that. unresolved-proc-macro is already meant to be unintrusive and easy to ignore though, so that users are aware that the macro is being ignored, without having red lines all over the place.

@jonas-schievink
Copy link
Contributor Author

And this seems to result in false positives for derive helpers like #[serde(rename = "edition")], seems like we need to register those... somewhere?

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

Successfully merging this pull request may close these issues.

3 participants