Skip to content

Overflow evaluating the requirement with a where clause on associated type #87755

Open
@bugaevc

Description

@bugaevc

I tried this code (playground):

#![feature(generic_associated_types)]

use std::fmt::Debug;

trait Foo {
    type Ass where Self::Ass: Debug;
}

#[derive(Debug)]
struct Bar;

impl Foo for Bar {
    type Ass = Bar;
}

Note that while it doesn't use GATs, it requires feature(generic_associated_types) for the where clause on the associated type to be allowed.

I expected to see this happen: this should build without errors.

Instead, this happened:

error[E0275]: overflow evaluating the requirement `<Bar as Foo>::Ass == _`
  --> src/lib.rs:12:5
   |
12 |     type Ass = Bar;
   |     ^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0275`.

Error E0275 explanation uses this example:

trait Foo {}

struct Bar<T>(T);

impl<T> Foo for T where Bar<T>: Foo {}

where indeed there's a recursive requirement that can't be checked in a small number of steps. Not so in my example: there's no recursion; Bar clearly implements Debug (and Foo).

@rustbot modify labels: +A-associated-items +F-generic_associated_types

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)A-associated-itemsArea: Associated items (types, constants & functions)GATs-triagedIssues using the `generic_associated_types` feature that have been triagedS-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions