Open
Description
This is an issue we came across in Firefox. Note that the Animate
impls are derived (including the where
clause), which made it a bit more subtle. This is a reduced example of what's going on:
trait Animate : Sized {
fn animate(&self) {}
}
struct GenericFoo<T> {
something: i32,
fallback: T,
}
enum GenericBar<T> {
None,
TheThing(T),
Foo(Box<GenericFoo<Self>>),
}
impl Animate for i32 {}
impl Animate for f32 {}
impl<T: Animate> Animate for GenericFoo<T> {}
impl<T: Animate> Animate for GenericBar<T>
where
GenericFoo<Self>: Animate,
{}
fn main() {
let bar = GenericBar::<f32>::None;
bar.animate();
}
I expect this code to work (like it does if you remove the where GenericFoo<Self>: Animate
), or at least provide a more descriptive error message (something about the where clause being cyclic or something, which is what I assume is going on, as GenericFoo<Self>: Animate
requires Self: Animate
?)
Instead, the compiler silently doesn't implement the trait for GenericBar<f32>
, and there's nothing in the error output which would point you to the culprit (the where
clause).
Meta
rustc --version --verbose
:
rustc 1.89.0-nightly (16d2276fa 2025-05-16)
But happens also in stable.