rust-lang / rust-lang/rust-analyzer

problems with associated types and code assist

Open
#22,387 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

trait Test2 {
    fn test2();
}

trait Test1 {
    type A: Test2;

    fn test1();
}

fn test<H: Test1>(test: H) {
    Test1::<Problem1>
    H::<Problem1>
    Test1::A::<Problem2>
    H::A::<Problem2>
}
  • Problem1:
    Code suggestions are different. While Test1:: offers the expected A and test1(), H:: adds stuff that doesn't make sense (like a clone() function).

  • Problem2:
    Code assist shows tons of types and methods. One of which are the proper members, but sometimes even that doesn't work (which is why I'm actually reporting this, but I haven't nailed it when that happens. So I thought maybe solve these 2 issues first ...)

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 reproducing the provided Rust snippet in rust-analyzer's code assist and compare completions for Test1::, H::, Test1::A::, and H::A::. Trace the completion entry point that produces these suggestions, then verify that associated types and methods are filtered consistently and that the relevant completions are present.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.