rust-lang / rust-lang/rust-analyzer
Better assists for `type annotations needed, consider specifying the generic argument`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
For example: given an iter: Iterator<Item=f64> if i call iter.sum() isn't it most likely that I want to sum them up to f64? In fact I believe that is the only possible output, yet sometimes the rustc type inference engine refuses to use that (iter.sum() / x). I kind of understand why, but maybe rust-analyzer can make smarter suggestions?
We could either program in a few common patterns like the one I mentioned above (maybe ask the community?) . Or implement more complete exhaustive checking on-demand as part of assists where the rustc trait resolver/type inference engine failed. Maybe both as I imagine the former is a lot more performant.
Note: I would actually be open to doing the implementation legwork on this if its a good beginner issue to get into the rust-analyzer codebase.
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 by examining rust-analyzer's assists and how they interact with the rustc type inference engine and trait resolver. Define whether the first milestone is support for common patterns such as Iterator<Item=f64>.sum() or more exhaustive on-demand checking, then establish tests for the proposed suggestions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100