Skip to content

Overflow on requirement evaluation with associated types #40594

@ebfull

Description

@ebfull
trait Foo { }

trait Bar<P> {
    type X;
}

impl<T, U> Foo for (T, U)
    where T: Bar<(T, U), X=U>
{ }

impl<T, P: Foo> Bar<P> for T {
    type X = u32;
}

fn main() { }

produces on stable and nightly:

error[E0275]: overflow evaluating the requirement `<T as Bar<(T, U)>>::X`
 --> src/lol.rs:7:1
  |
7 |   impl<T, U> Foo for (T, U)
  |  _^ starting here...
8 | |     where T: Bar<(T, U), X=U>
9 | | { }
  | |___^ ...ending here
  |
  = note: required because of the requirements on the impl of `Foo` for `(T, U)`
  = note: required because of the requirements on the impl of `Bar<(T, U)>` for `T`

error: aborting due to previous error

The impl's compile individually but not together. I expect it to be able to compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemC-bugCategory: This is a bug.T-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.

    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