rust-lang / rust-lang/rust-analyzer

Implement missing members suggestion shadows type parameters

Open
#6,870 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-assists S-actionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

In the following minimal example in latest nightly (using a struct<T> DiagnosticResult { ... }), the "implement missing members" intention shadows the type parameter T.
image
image
This creates rather confusing error messages if you didn't actually read the code that it inserted!
image
The two type parameters T and T are different, but I imagine that in a more complex scenario than this, it could hide the source of bugs. I think rust-analyzer should probably output code similar to
image

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

Reproduce the minimal struct<T> DiagnosticResult example and invoke the “implement missing members” intention. Trace the intention's generated code and verify that its type parameter does not shadow the existing T; the issue is done when the inserted code uses a distinct parameter name and no longer causes the confusing errors shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.