-
Notifications
You must be signed in to change notification settings - Fork 32
/
point-to-type-err-cause-on-impl-trait-return.rs
113 lines (100 loc) · 2.1 KB
/
point-to-type-err-cause-on-impl-trait-return.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
fn foo() -> impl std::fmt::Display {
if false {
return 0i32;
}
1u32 //~ ERROR mismatched types
}
fn bar() -> impl std::fmt::Display {
if false {
return 0i32;
} else {
return 1u32; //~ ERROR mismatched types
}
}
fn baz() -> impl std::fmt::Display {
if false {
return 0i32;
} else {
1u32 //~ ERROR mismatched types
}
}
fn qux() -> impl std::fmt::Display {
if false {
0i32
} else {
1u32 //~ ERROR `if` and `else` have incompatible types
}
}
fn bat() -> impl std::fmt::Display {
match 13 {
0 => return 0i32,
_ => 1u32, //~ ERROR mismatched types
}
}
fn can() -> impl std::fmt::Display {
match 13 { //~ ERROR mismatched types
0 => return 0i32,
1 => 1u32,
_ => 2u32,
}
}
fn cat() -> impl std::fmt::Display {
match 13 {
0 => {
return 0i32;
}
_ => {
1u32 //~ ERROR mismatched types
}
}
}
fn dog() -> impl std::fmt::Display {
match 13 {
0 => 0i32,
1 => 1u32, //~ ERROR `match` arms have incompatible types
_ => 2u32,
}
}
fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
match 13 {
0 => {
return 0i32;
}
_ => {
1u32
}
}
}
fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
match 13 {
0 => 0i32,
1 => 1u32,
_ => 2u32,
}
}
fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object
if false {
0i32
} else {
1u32
}
}
fn apt() -> impl std::fmt::Display {
if let Some(42) = Some(42) {
0i32
} else {
1u32 //~ ERROR `if` and `else` have incompatible types
}
}
fn main() {}
// ferrocene-annotations: fls_fk2m2irwpeof
// Implementations
//
// ferrocene-annotations: fls_qa98qdi42orq
// Trait Object Type
//
// ferrocene-annotations: fls_85vx1qfa061i
// Traits
//
// ferrocene-annotations: fls_exe4zodlwfez
// Type Unification