Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tomaka opened this issue Nov 5, 2018 · 2 comments
Closed
Labels
A-associated-items Area: Associated items (types, constants & functions) A-trait-system Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tomaka
Copy link
Contributor

tomaka commented Nov 5, 2018

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.

@jonas-schievink jonas-schievink added A-trait-system Area: Trait system A-associated-items Area: Associated items (types, constants & functions) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 27, 2019
@Globidev
Copy link

Globidev commented Mar 9, 2021

The code from the playground seems to compile fine since rust 1.49.0
I can't pinpoint to the exact PR that solved it but this issue seems to be fixed 🙂

@tomaka
Copy link
Contributor Author

tomaka commented Mar 9, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-trait-system Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants