rust-lang / rust-lang/rust-analyzer
Renaming isn't aware of different namespaces
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Given the following source:
mod foo {
pub mod bar {
pub fn inner() {}
}
pub const bar: () = ();
}
use foo::bar;
fn main() {
bar::inner();
}
renaming the const bar to something else like bar2 breaks the code as it emits:
mod foo {
pub mod bar {
pub fn inner() {}
}
pub const bar2: () = ();
}
use foo::bar2;
fn main() {
bar::inner(); // now unresolved
}
The general problem already exists for path resolution as the preference there is kind of hardcoded at the moment, but even with that fixed renaming requires knowledge of whether a reference might be occupying multiple namespaces or not in use statements.
For consts this isn't too pressing of a matter as the capitalization is usually different, but for macros this can cause problems more easily as those names tend to clash with modules/functions.
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 rename implementation and its path-resolution handling, then trace how use statements and references are classified across Rust namespaces. Reproduce the example and verify that renaming the const preserves the module reference while also updating references that actually target the const, including macro-related cases.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100