`unconstrained type parameter` with associated types that are actually constrained
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code (playground):
pub trait Marker {}
pub trait Foo {
type Bar;
}
struct Baz<T>(T);
impl<T> Foo for Baz<T> {
type Bar = Baz<T>;
}
impl<T> Marker for <Baz<T> as Foo>::Bar {}
I expected to see this happen: successful compilation
Instead, this happened: compilation error:
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
--> src/main.rs:13:6
|
13 | impl<T> Marker for <Baz<T> as Foo>::Bar {}
| ^ unconstrained type parameter
For more information about this error, try `rustc --explain E0207`.
error: could not compile `tmp` (bin "tmp") due to 1 previous error
And this confuses me, as clearly the T is being used in the associated type of Baz.
I searched around for other issues similar to this, but I couldn't find one matching exactly with this problem.
Meta
rustc --version --verbose:
rustc 1.88.0-nightly (092a284ba 2025-04-13)
binary: rustc
commit-hash: 092a284ba0421695f2032c947765429fd7095796
commit-date: 2025-04-13
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
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 compiling the linked Rust playground reproduction with the reported nightly version and confirm the E0207 diagnostic. Investigate how unconstrained type parameters are checked when an associated type contains the parameter; done means the example compiles as expected or the intended behavior is covered by an appropriate compiler test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100