`Assoc: Trait` constraints with projection types in generics fail to type-check
Open
Nobody has claimed this yet.
A-trait-system
C-bug
fixed-by-next-solver
T-types
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
pub trait TriviallyProject {
type Out;
}
impl TriviallyProject for () {
type Out = ();
}
pub trait MyTrait<T> {
type Assoc;
}
fn meow<T: MyTrait<(), Assoc: Default>>() {}
fn mewo<T: MyTrait<<() as TriviallyProject>::Out, Assoc: Default>>() {}
I expected to see this happen: both meow and mewo should compile since () and <() as TriviallyProject>::Out should normalize to the same type
Instead, this happened:
error[E0277]: the trait bound `T: MyTrait<()>` is not satisfied
--> src/lib.rs:15:1
|
15 | fn mewo<T: MyTrait<<() as TriviallyProject>::Out, Assoc: Default>>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait<()>` is not implemented for `T`
error[E0277]: the trait bound `T: MyTrait<()>` is not satisfied
--> src/lib.rs:15:12
|
15 | fn mewo<T: MyTrait<<() as TriviallyProject>::Out, Assoc: Default>>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait<()>` is not implemented for `T`
Here's a playground link.
Meta
rustc --version --verbose:
% rustc +nightly --version --verbose
rustc 1.95.0-nightly (1ed488274 2026-02-25)
binary: rustc
commit-hash: 1ed488274bec5bf5cfe6bf7a1cc089abcc4ebd68
commit-date: 2026-02-25
host: aarch64-apple-darwin
release: 1.95.0-nightly
LLVM version: 22.1.0
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 reproducing the generic example from the issue with the linked Rust Playground and the reported nightly compiler version. Trace how rustc handles the MyTrait<<() as TriviallyProject>::Out> bound, then add a regression test showing that the projection-normalized form type-checks like MyTrait<()>.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100