rust-lang / rust-lang/rust-analyzer
Rename on an imported type should rename the import to an alias.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I'm not sure if this is valid request, but please feel free to close it, if it is.
When I tried to rename an imported type, hoping it will rename it to an alias, but it just returned an error: "Can't rename non-local definition".
But when I searched, I found that rename will alias an import, if we are in the use tree when invoking it, so I was wondering if we could extend to any imported type or the at least non-local crate imports?
Simple example:
use std::collections::HashMap
struct Foo {
map: HashMap$0,
}
Invoking rename on the cursor should create an alias import:
use std::collections::HashMap as StdHashMap;
struct Foo {
map: StdHashMap$0,
}
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
No implementation files or tests are named. Start by tracing rename handling for imported types and the existing use-tree behavior that already creates aliases; done means renaming an imported type from its usage site creates the expected import alias and updates the reference without the non-local-definition error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100