rust-lang / rust-lang/rust-analyzer
Macro v2 can see private items, but we don't name resolve it
Open
Nobody has claimed this yet.
A-hygiene
A-macro
A-nameres
C-bug
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Rustc accepts this code, but we don't:
#![feature(decl_macro)]
mod privacy_boundary {
mod inner {
pub fn x() -> i32 {
5
}
}
pub macro m() {
$crate::privacy_boundary::inner::x()
}
}
use privacy_boundary::m;
fn main() {
let v = m!(); // we report the type of v as {unknown}
dbg!(v);
}
Somehow unrelated: maybe we should resolve names even if they are private?
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 supplied Rust reproducer and compare rust-analyzer's result with rustc's accepted behavior; no file or test is named. Trace macro v2 name resolution across the privacy boundary, and consider the issue complete when the example resolves v as i32 instead of {unknown}, with the behavior covered by a test.
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