rust-lang / rust-lang/rust-analyzer
[Feature Request]: Code action to suggestion types that satisfy a set of traits using Chalk
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I've come across a case where I have a generic struct that whose type parameter needs to satisfy two traits.
pub struct FileReader<R: Read + Seek> { /* private fields */ }
These are standard traits and I can find their implementors individually. Then I can see which implementors are common and use one of them.
However this made me consider if there's a way to query the IDE for possible structs/types that implement a given set of traits. This might be useful when generics have many trait conditions and/or a trait has many implementors.
I've asked this on SO and rust internals. There it was discussed that chalk, the new trait resolver, can potentially answer queries like this.
Now since rust-analyzer has integrated with chalk. Is it possible to answer queries like this? Kind of like an auto-complete code action, where the the analyzer can make recommendations.
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 reviewing rust-analyzer's Chalk integration and the code-action handling relevant to type and trait resolution; then determine whether queries for types satisfying multiple traits can be represented. Done means the analyzer can offer such recommendations with coverage for the requested behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100