]> git.lizzy.rs Git - rust.git/blob - tests/ui/impl-trait/equality.rs
Rollup merge of #106097 - mejrs:mir_build2, r=oli-obk
[rust.git] / tests / ui / impl-trait / equality.rs
1 #![feature(specialization)] //~ WARN the feature `specialization` is incomplete
2
3 trait Foo: Copy + ToString {}
4
5 impl<T: Copy + ToString> Foo for T {}
6
7 fn hide<T: Foo>(x: T) -> impl Foo {
8     x
9 }
10
11 fn two(x: bool) -> impl Foo {
12     if x {
13         return 1_i32;
14     }
15     0_u32
16     //~^ ERROR mismatched types
17     //~| expected `i32`, found `u32`
18 }
19
20 fn sum_to(n: u32) -> impl Foo {
21     if n == 0 {
22         0
23     } else {
24         n + sum_to(n - 1)
25         //~^ ERROR cannot add `impl Foo` to `u32`
26     }
27 }
28
29 trait Leak: Sized {
30     type T;
31     fn leak(self) -> Self::T;
32 }
33 impl<T> Leak for T {
34     default type T = ();
35     default fn leak(self) -> Self::T { panic!() }
36 }
37 impl Leak for i32 {
38     type T = i32;
39     fn leak(self) -> i32 { self }
40 }
41
42 fn main() {
43 }