3 #![feature(coerce_unsized)]
5 // Ensure that unsizing structs that contain ZSTs at non-zero offsets don't ICE
7 use std::ops::CoerceUnsized;
10 pub struct BoxWithZstTail<T: ?Sized>(Box<T>, ());
12 impl<S: ?Sized, T: ?Sized> CoerceUnsized<BoxWithZstTail<T>> for BoxWithZstTail<S> where
13 Box<S>: CoerceUnsized<Box<T>>
17 pub fn noop_dyn_upcast_with_zst_tail(
18 b: BoxWithZstTail<dyn ToString + Send>,
19 ) -> BoxWithZstTail<dyn ToString> {
25 let boxed = BoxWithZstTail(Box::new(original) as Box<dyn ToString + Send>, ());
26 let noop_upcasted = noop_dyn_upcast_with_zst_tail(boxed);
27 assert_eq!(original, noop_upcasted.0.to_string());