Skip to content

Adding a equality constraint on an associated type can break the checks #55697

Closed
@tomaka

Description

@tomaka

The following code works fine:

trait Upgr<S> {}

trait Proto {
    type S;
    type Upgr: Upgr<Self::S>;
}

struct Wrapper<P>(P);

impl<P: Proto> Proto for Wrapper<P> {
    type S = P::S;
    type Upgr = P::Upgr;
}

However if you change the last few lines for this:

impl<X, P: Proto<S = X>> Proto for Wrapper<P> {
    type S = P::S;
    type Upgr = P::Upgr;
}

Then you get:

error[E0277]: the trait bound <P as Proto>::Upgr: Upgr<X> is not satisfied

(link to playground)

Using type S = X; also doesn't work.

Rust version: nightly.
Apologize if an issue already exists. The vocabulary for this kind of problems is kind of tricky, which makes it hard to search for existing issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-trait-systemArea: Trait systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions