rust-lang / rust-lang/rust-analyzer
Consider present type aliases when using quick fixes
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Using libraries like ndarray you have a lot of type aliases e.g. Array2<f64> because the actual types are quite complex e.g. ArrayBase<ndarray::OwnedRepr<f64>, ndarray::Dim<[usize; 2]>>.
While in an ideal world, rust-analyzer could know to import the correct type alias if you use e.g. Add this functions return type. In reality, it would probably be unfeasible to search for those. What I imagine could be possible is to at least look at all imported type aliases and if there is one in scope that matches, use that one.
An alternative could be to add a code-action when on a type to "search for matching type alias" or something like that. I'm not familiar with how RA can access the available types, so I am not sure if this can be done, but it does sound possible to me.
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
The issue names no files or tests; start by locating the quick-fix implementation for generated return types and how imported type aliases are represented. Compare the proposed in-scope alias matching with the alternative search code action, then define one focused behavior. Done means the chosen behavior is specified and its matching cases are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100