Skip to content

Trait bounds are not propagated through type equality constraints #85243

New issue

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

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

Already on GitHub? # to your account

Closed
programmerjake opened this issue May 13, 2021 · 1 comment
Closed
Labels
C-bug Category: This is a bug.

Comments

@programmerjake
Copy link
Member

I tried this code:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e13f9ef0a5c88c03fca13d57418f4986

pub trait Trait1 {
    fn f();
}

pub trait Trait2 {
    type Type: Trait1;
}

pub trait Trait3 {
    type Type2: Trait2<Type = Self>;
    fn f2() {
        <Self as Trait1>::f();
    }
}

I expected to see this compile successfully since in Trait3, Self is guaranteed to implement Trait1 because Self = Trait2::Type and Trait2::Type: Trait1.

Instead, this happened:

error[E0277]: the trait bound `Self: Trait1` is not satisfied
@programmerjake programmerjake added the C-bug Category: This is a bug. label May 13, 2021
@jonas-schievink
Copy link
Contributor

Duplicate of #20671

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants