Skip to content

Overflow evaluating the requirement on associated_type_defaults bounded on the field it's being assigned #137434

Open
@udoprog

Description

@udoprog

I tried this code:

#![feature(associated_type_defaults)]

trait Trait {
    type A;
}

trait Other<T>
where
    T: Trait<A = Self::A>,
{
    type A = T::A;
}

See playground.

I expected the associated type default to compile since the bound is valid when implementing the trait. In my mind type A = T::A should be compatible with the T: Trait<A = Self::A> constraint;

Instead, this happened:

error[E0275]: overflow evaluating the requirement `<Self as UnsizedVisitor<T>>::A == _`
  --> src/lib.rs:12:14
   |
12 |     type A = T::A;
   |              ^^^^

Meta

rustc --version --verbose:

binary: rustc
commit-hash: 794c12416b2138064af1f2746646973fafd9419d
commit-date: 2025-02-21
host: x86_64-pc-windows-msvc
release: 1.87.0-nightly
LLVM version: 20.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-bugCategory: This is a bug.F-associated_type_defaults`#![feature(associated_type_defaults)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions