|
| 1 | +#![feature(unsize, dispatch_from_dyn, never_type)] |
| 2 | + |
| 3 | +#![allow(dead_code)] |
| 4 | + |
| 5 | +use std::{ |
| 6 | + ops::DispatchFromDyn, |
| 7 | + marker::{Unsize, PhantomData}, |
| 8 | +}; |
| 9 | + |
| 10 | +struct Zst; |
| 11 | +struct NestedZst(PhantomData<()>, Zst); |
| 12 | + |
| 13 | + |
| 14 | +struct WithUnit<T: ?Sized>(Box<T>, ()); |
| 15 | +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<WithUnit<U>> for WithUnit<T> |
| 16 | + where T: Unsize<U> {} |
| 17 | + |
| 18 | +struct WithPhantom<T: ?Sized>(Box<T>, PhantomData<()>); |
| 19 | +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<WithPhantom<U>> for WithPhantom<T> |
| 20 | + where T: Unsize<U> {} |
| 21 | + |
| 22 | +struct WithNever<T: ?Sized>(Box<T>, !); |
| 23 | +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<WithNever<U>> for WithNever<T> |
| 24 | + where T: Unsize<U> {} |
| 25 | + |
| 26 | +struct WithZst<T: ?Sized>(Box<T>, Zst); |
| 27 | +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<WithZst<U>> for WithZst<T> |
| 28 | + where T: Unsize<U> {} |
| 29 | + |
| 30 | +struct WithNestedZst<T: ?Sized>(Box<T>, NestedZst); |
| 31 | +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<WithNestedZst<U>> for WithNestedZst<T> |
| 32 | + where T: Unsize<U> {} |
| 33 | + |
| 34 | + |
| 35 | +struct Generic<T: ?Sized, A>(Box<T>, A); |
| 36 | +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Generic<U, ()>> for Generic<T, ()> |
| 37 | + where T: Unsize<U> {} |
| 38 | +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Generic<U, PhantomData<()>>> |
| 39 | + for Generic<T, PhantomData<()>> |
| 40 | + where T: Unsize<U> {} |
| 41 | +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Generic<U, !>> for Generic<T, !> |
| 42 | + where T: Unsize<U> {} |
| 43 | +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Generic<U, Zst>> for Generic<T, Zst> |
| 44 | + where T: Unsize<U> {} |
| 45 | +impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Generic<U, NestedZst>> for Generic<T, NestedZst> |
| 46 | + where T: Unsize<U> {} |
| 47 | + |
| 48 | + |
| 49 | +fn main() {} |
0 commit comments