rust-lang / rust-lang/rust-analyzer

Better assists for `type annotations needed, consider specifying the generic argument`

Open
#17,202 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.