Trait bound in associated type isn't checked when normalizing type that doesn't require inspecting the AT
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the standalone Rust reproducer from the issue and confirm that the shown associated-type normalization accepts i64 despite its missing Bound implementation. Trace the compiler's trait-bound checking and normalization behavior for this case; done means the reproducer is rejected with an appropriate bound error and regression coverage exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100