//@ known-bug: rust-lang/rust#129219 //@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir --edition=2018 use core::marker::Unsize; pub trait CastTo: Unsize {} impl CastTo for U {} impl Cast for T {} pub trait Cast { fn cast(&self) -> &T where Self: CastTo, { self } } pub trait Foo {} impl Foo for [i32; 0] {} fn main() { let x: &dyn Foo = &[]; let x = x.cast::<[i32]>(); }