//@ check-pass #![feature(derive_coerce_pointee)] #![feature(arbitrary_self_types)] use std::ops::Deref; use std::marker::CoercePointee; use std::sync::Arc; trait MyTrait {} #[derive(CoercePointee)] #[repr(transparent)] struct MyArc where T: MyTrait + ?Sized, { inner: Arc } impl Deref for MyArc { type Target = T; fn deref(&self) -> &T { &self.inner } } // Proving that `MyArc` is dyn-dispatchable requires proving `MyArc` implements // `DispatchFromDyn>`. The `DispatchFromDyn` impl that is generated from the // `CoercePointee` implementation requires the pointee impls `MyTrait`, but previously we // were only assuming the pointee impl'd `MyOtherTrait`. Elaboration comes to the rescue here. trait MyOtherTrait: MyTrait { fn foo(self: MyArc); } fn test(_: MyArc) {} fn main() {}