]> git.proxmox.com Git - rustc.git/blame - src/test/ui/impl-trait/equality.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / src / test / ui / impl-trait / equality.rs
CommitLineData
f035d41b 1#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
5bcae85e
SL
2
3trait Foo: Copy + ToString {}
4
5impl<T: Copy + ToString> Foo for T {}
6
7fn hide<T: Foo>(x: T) -> impl Foo {
8 x
9}
10
11fn two(x: bool) -> impl Foo {
12 if x {
13 return 1_i32;
14 }
15 0_u32
16 //~^ ERROR mismatched types
60c5eb7d 17 //~| expected `i32`, found `u32`
5bcae85e
SL
18}
19
ee023bcb 20fn sum_to(n: u32) -> impl Foo {
5bcae85e
SL
21 if n == 0 {
22 0
23 } else {
24 n + sum_to(n - 1)
2c00a5a8 25 //~^ ERROR cannot add `impl Foo` to `u32`
5bcae85e
SL
26 }
27}
28
29trait Leak: Sized {
30 type T;
31 fn leak(self) -> Self::T;
32}
33impl<T> Leak for T {
34 default type T = ();
35 default fn leak(self) -> Self::T { panic!() }
36}
37impl Leak for i32 {
38 type T = i32;
39 fn leak(self) -> i32 { self }
40}
41
5bcae85e 42fn main() {
5bcae85e 43}