rust-lang / rust-lang/rust-analyzer
macro calls emitting macro definitions resolve badly
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Edit: Core no longer relies on this, the bug itself is still a thing though
The core library unfortunately started using the weird macro pattern where a macro invocation produces a textually scoped macro that is immediately invoked again. This works fine for r-a if the macro is only used once in a given scope, but the core library uses it several times. All consecutive uses of the inner produced macro unfortunately resolve to the very first one, meaning all impls produced by this macro end up being for StructuralEq.
https://github.com/rust-lang/rust/blob/77fb0cd3aa276919e00397f526616c5036562ea1/library/core/src/marker.rs#L44C1-L67
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 with the macro pattern in library/core/src/marker.rs, especially the linked lines, and trace how rust-analyzer resolves repeated invocations of the produced, textually scoped macro. Reproduce consecutive uses in the same scope and verify that each generated impl resolves independently rather than all resolving to StructuralEq.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100