rust-lang / rust-lang/rust-analyzer
Trying to rename "use alias" in VSCode messes up with files from other crates
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Hello. I'm not sure what is the "official" name of the renaming imports construct in Rust, so I'm referring to it as "use alias" both in the title and in the body of this issue. Fell free to fix this and delete this part, please.
What is wrong?
When trying to rename the "alias" part of the "use alias" using the Rename Symbol functionality from VSCode (F2), the original name is the one that gets replaced. Moreover, it seems that the change is applied to every source file that uses the previous original name as a mod name in every crate we depend on.
What should happen instead?
I expected that only the new name and its corresponding usages in the current file be changed.
MWE
main.rs
use std::io as foo;
fn main() {
let _ = foo::empty();
println!("Hello, world!");
}
Cargo.toml
Just the most basic
Steps taken
- click on the
foo"alias" - use the "Rename Symbol" utility (F2)
- enter the value "
bar" - bug!
4.1. A lot of files get opened by VSCode, none of them from our crate
4.2 All of the opened files have changes relating to the renaming we tried to do
System info
- Using VSCode 1.46.1
- rust-analyser 0.2.224 extension
- Using rustc 1.44.1
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 main.rs and Cargo.toml example, then reproduce the VSCode F2 rename on the foo alias from std::io. Inspect the rename behavior across the current crate and dependent crates. Done means renaming foo to bar changes only the alias and its corresponding usages in the current file, without opening or modifying unrelated files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100