1 #![feature(specialization)] //~ WARN the feature `specialization` is incomplete
3 trait Foo: Copy + ToString {}
5 impl<T: Copy + ToString> Foo for T {}
7 fn hide<T: Foo>(x: T) -> impl Foo {
13 fn leak(self) -> Self::T;
17 default fn leak(self) -> Self::T { panic!() }
21 fn leak(self) -> i32 { self }
25 let _: u32 = hide(0_u32);
26 //~^ ERROR mismatched types
27 //~| expected type `u32`
28 //~| found opaque type `impl Foo`
29 //~| expected `u32`, found opaque type
31 let _: i32 = Leak::leak(hide(0_i32));
32 //~^ ERROR mismatched types
33 //~| expected type `i32`
34 //~| found associated type `<impl Foo as Leak>::T`
35 //~| expected `i32`, found associated type
37 let mut x = (hide(0_u32), hide(0_i32));
39 //~^ ERROR mismatched types
40 //~| expected `u32`, found `i32`
42 //~^ ERROR mismatched types
43 //~| expected `i32`, found `u32`