Skip to content

Only suggest trait method completions when all (method) bounds are satisfied. #20562

@Philipp-M

Description

@Philipp-M

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-featureCategory: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions