//@ compile-flags: -Zmir-opt-level=0 -Zmir-enable-passes=+Inline,+GVN -Zvalidate-mir #![feature(unsize)] use std::marker::Unsize; pub trait CastTo: Unsize {} // Not well-formed! impl CastTo for T {} //~^ ERROR the trait bound `T: Unsize` is not satisfied pub trait Cast { fn cast(&self) where Self: CastTo; } impl Cast for T { #[inline(always)] fn cast(&self) where Self: CastTo, { let x: &U = self; } } fn main() { // When we inline this call, then we run GVN, then // GVN tries to evaluate the `() -> [i32]` unsize. // That's invalid! ().cast::<[i32]>(); }