rust-lang / rust-lang/rust-analyzer
Only suggest trait method completions when all (method) bounds are satisfied.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Consider the following:
struct Color;
trait HasProperty<P> {}
trait Style {
fn color(self)
where
Self: Sized + HasProperty<Color>,
{
}
}
impl<T> Style for T {}
struct WithoutColor;
I'd expect that WithoutColor.| doesn't show any color() as it doesn't fullfill the method trait bounds, but it does, and after completion cargo check fails (i.e. shows an error).
I haven't seen these kind of issues with super-trait-bounds on traits, something like Style: HasProperty<Color> (i.e. works as expected).
(This is a trimmed down example of an actual case in Xilem, in case you're interested, you can try the examples, there's a Style trait that does something similar).
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 with the minimal Rust example in the issue and reproduce completion for WithoutColor.|, then compare the offered methods with the result of cargo check. Investigate rust-analyzer's method-completion handling for method trait bounds and use the linked Xilem examples as a broader reproduction; done means color() is omitted when its bounds are unsatisfied without changing valid completions.
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
- 45/100