Skip to content

Asymmetric "overflow evaluating the requirement" error with associated type constraint #72098

@tavianator

Description

@tavianator

This code gives an error:

trait Foo {
    type Bar;
}

trait Baz<T: ?Sized + Foo>: Foo<Bar = T::Bar> {}

trait Qux: Baz<Self> {}
error[E0275]: overflow evaluating the requirement `<Self as Foo>::Bar`
 --> foo.rs:7:1
  |
7 | trait Qux: Baz<Self> {}
  | ^^^^^^^^^^^^^^^^^^^^^^^

Yet, moving the constraint to T instead of Self works fine:

trait Baz<T: ?Sized + Foo<Bar = <Self as Foo>::Bar>>: Foo {}

Since T = Self in the context of Qux, it's surprising this makes a difference.

Meta

rustc --version --verbose:

rustc 1.45.0-nightly (7ebd87a7a 2020-05-08)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-type-systemArea: Type systemC-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions