Skip to content

Trait bound in associated type isn't checked when normalizing type that doesn't require inspecting the AT #154172

@theemathas

Description

@theemathas

The below code shouldn't compile, since i64 does not implement Bound, so I shouldn't be allowed to write Output<i64>. However, it compiles without errors.

I'm guessing that rustc sees <.... as Super>::Assoc and immediately concludes that the type must be i32 without further checking.

trait Super {
    type Assoc;
}
trait Sub: Super<Assoc = i32> {}

// no impl for Bound anywhere
trait Bound {}

trait Apply {
    // Bound requirement here
    type Output<T: Bound>: Sub;
}

trait Trait {
    type What;
}

impl<A: Apply> Trait for A {
    // i64 doesn't implement Bound
    type What = <<A as Apply>::Output<i64> as Super>::Assoc;
}

cc @lcnr

Meta

Reproducible on the playground with version 1.96.0-nightly (2026-03-12 3102493c71626b5912d1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-trait-systemArea: Trait systemC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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