rust-lang / rust-lang/rust-analyzer
Trait method should not appear in the auto complete if bounds not satisfied
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Hi,
Using rust nightly rustc 1.89.0-nightly (777d37277 2025-05-17).
I will copy paste the question I asked on the (rust forum) with a playground link.
Hi,
The issue:
I would like Vscode/rust-analyzer not to show some trait functions in auto complete if the bounds are not satisfied.
I mean, for the type B in the playground, ra still show get_value_from_key when it should only show get_value_from_key2 and vice versa for A when auto-complete popup is displayed.
(This is a very simplified example, the trait is much more complex than this with dozen of functions with varying constraints)
Is there a way to make that behave properly?
Thanks!
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 reproducing the autocomplete behavior from the linked Rust Playground example in rust-analyzer with the reported nightly toolchain. Trace the trait-method completion handling and verify that methods whose bounds are unsatisfied are omitted while applicable methods remain visible.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100