//@ check-pass #![feature(coerce_unsized)] // Ensure that unsizing structs that contain ZSTs at non-zero offsets don't ICE use std::ops::CoerceUnsized; #[repr(C)] pub struct BoxWithZstTail(Box, ()); impl CoerceUnsized> for BoxWithZstTail where Box: CoerceUnsized> { } pub fn noop_dyn_upcast_with_zst_tail( b: BoxWithZstTail, ) -> BoxWithZstTail { b } fn main() { let original = "foo"; let boxed = BoxWithZstTail(Box::new(original) as Box, ()); let noop_upcasted = noop_dyn_upcast_with_zst_tail(boxed); assert_eq!(original, noop_upcasted.0.to_string()); }