This works (playpen):
use std::marker::PhantomData;
trait X {
type Q;
}
trait Y { }
struct Z<T> { t: PhantomData<T> }
impl<'a, T> X for Z<T> where T: 'a, &'a T: Y {
type Q = u8;
}
If instead we add an associated type Z to Y and try to write type Q = <&'a T as Y>::Z; in the X implementation, it fails with "error[E0207]: the lifetime parameter 'a is not constrained by the impl trait, self type, or predicates" (playpen:
use std::marker::PhantomData;
trait X {
type Q;
}
trait Y {
type Z;
}
struct Z<T> { t: PhantomData<T> }
impl<'a, T> X for Z<T> where T: 'a, &'a T: Y {
type Q = <&'a T as Y>::Z;
}
Rust version: doesn't seem to matter; all of stable, beta, and nightly on play.rlo produce the same results.
Thanks to @QuietMisdreavus on IRC for helping with the reduced example.
This works (playpen):
If instead we add an associated type
ZtoYand try to writetype Q = <&'a T as Y>::Z;in theXimplementation, it fails with "error[E0207]: the lifetime parameter'ais not constrained by the impl trait, self type, or predicates" (playpen:Rust version: doesn't seem to matter; all of stable, beta, and nightly on play.rlo produce the same results.
Thanks to @QuietMisdreavus on IRC for helping with the reduced example.