Open
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