blob: 967958ab48695bcf27eb27313eb35afba8316528 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#![feature(arbitrary_self_types)]
#![feature(unsize)]
#![feature(dispatch_from_dyn)]
use std::marker::PhantomData;
use std::marker::Unsize;
use std::ops::DispatchFromDyn;
use std::ops::Deref;
struct IsSendToken<T: ?Sized>(PhantomData<fn(T) -> T>);
struct Foo<'a, U: ?Sized> {
token: IsSendToken<U>,
ptr: &'a U,
}
impl<'a, T, U> DispatchFromDyn<Foo<'a, U>> for Foo<'a, T>
//~^ ERROR implementing `DispatchFromDyn` does not allow multiple fields to be coerced
where
T: Unsize<U> + ?Sized,
U: ?Sized {}
trait Bar {
fn f(self: Foo<'_, Self>);
}
impl<U: ?Sized> Deref for Foo<'_, U> {
type Target = U;
fn deref(&self) -> &U {
self.ptr
}
}
fn main() {}
|