//@ check-pass trait Mirror { type Other; } #[derive(Debug)] struct Even(usize); struct Odd; impl Mirror for Even { type Other = Odd; } impl Mirror for Odd { type Other = Even; } trait Dyn: AsRef<::Other> {} impl Dyn for Even {} impl AsRef for Even { fn as_ref(&self) -> &Even { self } } fn code(d: &dyn Dyn) -> &T::Other { d.as_ref() } fn main() { println!("{:?}", code(&Even(22))); }