rust-lang / rust-lang/rust-analyzer
Unresolved import with `macro_rules_attribute`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: rust-analyzer 1.69.0-nightly (8996ea9 2023-02-09)
rustc version: rustc 1.67.1 (d5a82bbd2 2023-02-07)
The following code runs/compiles fine, but in rust-analyzer yields an unresoved import error on use module::Struct, that seems to be caused by apply. Importing from the parent module works without error (i.e. use crate::NonModule does not produce any error).
#[macro_use]
extern crate macro_rules_attribute;
attribute_alias! {
#[apply(Test)] = #[derive(Debug)];
}
mod module {
use crate::NonModule;
#[apply(Test)]
pub struct Struct(pub NonModule);
}
use module::Struct;
#[apply(Test)]
pub struct NonModule;
fn main() {
println!("{:?}", Struct(NonModule));
println!("{NonModule:?}");
}
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 minimal Rust reproducer in the issue and run rust-analyzer against it with the shown macro_rules_attribute and #[apply(Test)] usage. Trace how the analyzer resolves use module::Struct versus use crate::NonModule. Done means the reproducer compiles without an erroneous unresolved-import diagnostic while preserving the existing valid behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100