]> git.lizzy.rs Git - rust.git/blob - src/test/ui/specialization/issue-44861.rs
Rollup merge of #73418 - doctorn:variants-intrinsic, r=kennytm
[rust.git] / src / test / ui / specialization / issue-44861.rs
1 #![crate_type = "lib"]
2 #![feature(specialization)]
3 #![feature(unsize, coerce_unsized)]
4 #![allow(incomplete_features)]
5
6 use std::ops::CoerceUnsized;
7
8 pub struct SmartassPtr<A: Smartass+?Sized>(A::Data);
9
10 pub trait Smartass {
11     type Data;
12     type Data2: CoerceUnsized<*const [u8]>;
13 }
14
15 pub trait MaybeObjectSafe {}
16
17 impl MaybeObjectSafe for () {}
18
19 impl<T> Smartass for T {
20     type Data = <Self as Smartass>::Data2;
21     default type Data2 = ();
22     //~^ ERROR: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied
23 }
24
25 impl Smartass for () {
26     type Data2 = *const [u8; 1];
27 }
28
29 impl Smartass for dyn MaybeObjectSafe {
30     type Data = *const [u8];
31     type Data2 = *const [u8; 0];
32 }
33
34 impl<U: Smartass+?Sized, T: Smartass+?Sized> CoerceUnsized<SmartassPtr<T>> for SmartassPtr<U>
35     where <U as Smartass>::Data: std::ops::CoerceUnsized<<T as Smartass>::Data>
36 {}
37
38 pub fn conv(s: SmartassPtr<()>) -> SmartassPtr<dyn MaybeObjectSafe> {
39     s
40 }