rust-lang / rust-lang/rust-analyzer
Consider doing pseudo attribute expansions™ for some inert attributes
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
https://github.com/rust-analyzer/rust-analyzer/pull/11513 made it so that we can expand derive attributes in a special way to downmap the input tokens into paths allowing a lot of IDE features to be simplified, removing a variety of hack in favor of one "unified hack".
From the looks of it this turned out really well. Now rust has a lot of inert attributes, that is builtin ones that do not exist in regards to a macro definition (derive was such a macro in the past as well but has been made a proper macro some versions ago).
These suffer from similar problems now, taking macro_use as an example one can do the following:
#[macro_use(foo)]
extern crate bar;
foo really is a reference to a macro of the bar crate, but for r-a (foo) is a TokenTree so if we want to resolve this usage, we need to hack it into all the places that want to deal with it, the same problem we have had with the derive attribute.
Clearly there is potential for a general solution here that does not only apply to the derive attribute (albeit the derive attribute is a special case of that then).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading PR 11513 and its derive-attribute expansion changes. Trace how rust-analyzer currently represents inert attributes such as macro_use(foo), then determine a general pseudo-attribute expansion approach that can support resolving the referenced macro without separate hacks. Done means the approach covers inert attributes generally, with derive treated as a special case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100