Skip to content

Trait bounds of associated types in where clauses result in unsatisfied requeriments #116749

Closed
@c410-f3r

Description

@c410-f3r

Feel free to close if duplicated.

pub trait Foo<TY> {
    type FooAssociatedTy;
}

pub trait Bar {
    type BarAssociatedTy;
    
    fn send<T>()
    where
        T: Foo<Self::BarAssociatedTy>,
        T::FooAssociatedTy: Send;
}

impl Bar for () {
    type BarAssociatedTy = ();

    fn send<T>()
    where
        T: Foo<()>,
        T::FooAssociatedTy: Send,
    {
    }
}

Taking aside the errors, a diagnostic suggests adding a weird T: Foo<()> + Foo<()> bound.

Things that will make everything compile:

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)A-trait-systemArea: Trait systemC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions