]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs
Rollup merge of #98441 - calebzulawski:simd_as, r=oli-obk
[rust.git] / src / test / ui / impl-trait / point-to-type-err-cause-on-impl-trait-return.rs
1 fn foo() -> impl std::fmt::Display {
2     if false {
3         return 0i32;
4     }
5     1u32 //~ ERROR mismatched types
6 }
7
8 fn bar() -> impl std::fmt::Display {
9     if false {
10         return 0i32;
11     } else {
12         return 1u32; //~ ERROR mismatched types
13     }
14 }
15
16 fn baz() -> impl std::fmt::Display {
17     if false {
18         return 0i32;
19     } else {
20         1u32 //~ ERROR mismatched types
21     }
22 }
23
24 fn qux() -> impl std::fmt::Display {
25     if false {
26         0i32
27     } else {
28         1u32 //~ ERROR `if` and `else` have incompatible types
29     }
30 }
31
32 fn bat() -> impl std::fmt::Display {
33     match 13 {
34         0 => return 0i32,
35         _ => 1u32, //~ ERROR mismatched types
36     }
37 }
38
39 fn can() -> impl std::fmt::Display {
40     match 13 { //~ ERROR mismatched types
41         0 => return 0i32,
42         1 => 1u32,
43         _ => 2u32,
44     }
45 }
46
47 fn cat() -> impl std::fmt::Display {
48     match 13 {
49         0 => {
50             return 0i32;
51         }
52         _ => {
53             1u32 //~ ERROR mismatched types
54         }
55     }
56 }
57
58 fn dog() -> impl std::fmt::Display {
59     match 13 {
60         0 => 0i32,
61         1 => 1u32, //~ ERROR `match` arms have incompatible types
62         _ => 2u32,
63     }
64 }
65
66 fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
67     match 13 {
68         0 => {
69             return 0i32;
70         }
71         _ => {
72             1u32
73         }
74     }
75 }
76
77 fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
78     match 13 {
79         0 => 0i32,
80         1 => 1u32, //~ ERROR `match` arms have incompatible types
81         _ => 2u32,
82     }
83 }
84
85 fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
86     if false {
87         0i32
88     } else {
89         1u32 //~ ERROR `if` and `else` have incompatible types
90     }
91 }
92
93 fn apt() -> impl std::fmt::Display {
94     if let Some(42) = Some(42) {
95         0i32
96     } else {
97         1u32 //~ ERROR `if` and `else` have incompatible types
98     }
99 }
100
101 fn main() {}