@@ -2,28 +2,43 @@ error[E0308]: mismatched types
2
2
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5
3
3
|
4
4
LL | fn foo() -> impl std::fmt::Display {
5
- | ---------------------- expected `_ ` because of return type
5
+ | ---------------------- expected `i32 ` because of return type
6
6
...
7
7
LL | 1u32
8
8
| ^^^^ expected `i32`, found `u32`
9
+ |
10
+ help: change the type of the numeric literal from `u32` to `i32`
11
+ |
12
+ LL | 1i32
13
+ | ~~~
9
14
10
15
error[E0308]: mismatched types
11
16
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:12:16
12
17
|
13
18
LL | fn bar() -> impl std::fmt::Display {
14
- | ---------------------- expected `_ ` because of return type
19
+ | ---------------------- expected `i32 ` because of return type
15
20
...
16
21
LL | return 1u32;
17
22
| ^^^^ expected `i32`, found `u32`
23
+ |
24
+ help: change the type of the numeric literal from `u32` to `i32`
25
+ |
26
+ LL | return 1i32;
27
+ | ~~~
18
28
19
29
error[E0308]: mismatched types
20
30
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:20:9
21
31
|
22
32
LL | fn baz() -> impl std::fmt::Display {
23
- | ---------------------- expected `_ ` because of return type
33
+ | ---------------------- expected `i32 ` because of return type
24
34
...
25
35
LL | 1u32
26
36
| ^^^^ expected `i32`, found `u32`
37
+ |
38
+ help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
39
+ |
40
+ LL | }.try_into().unwrap()
41
+ | ++++++++++++++++++++
27
42
28
43
error[E0308]: `if` and `else` have incompatible types
29
44
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:28:9
@@ -36,36 +51,56 @@ LL | | 1u32
36
51
| | ^^^^ expected `i32`, found `u32`
37
52
LL | | }
38
53
| |_____- `if` and `else` have incompatible types
54
+ |
55
+ help: change the type of the numeric literal from `u32` to `i32`
56
+ |
57
+ LL | 1i32
58
+ | ~~~
39
59
40
60
error[E0308]: mismatched types
41
61
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:35:14
42
62
|
43
63
LL | fn bat() -> impl std::fmt::Display {
44
- | ---------------------- expected `_ ` because of return type
64
+ | ---------------------- expected `i32 ` because of return type
45
65
...
46
66
LL | _ => 1u32,
47
67
| ^^^^ expected `i32`, found `u32`
68
+ |
69
+ help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
70
+ |
71
+ LL | }.try_into().unwrap()
72
+ | ++++++++++++++++++++
48
73
49
74
error[E0308]: mismatched types
50
75
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:40:5
51
76
|
52
77
LL | fn can() -> impl std::fmt::Display {
53
- | ---------------------- expected `_ ` because of return type
78
+ | ---------------------- expected `i32 ` because of return type
54
79
LL | / match 13 {
55
80
LL | | 0 => return 0i32,
56
81
LL | | 1 => 1u32,
57
82
LL | | _ => 2u32,
58
83
LL | | }
59
84
| |_____^ expected `i32`, found `u32`
85
+ |
86
+ help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
87
+ |
88
+ LL | }.try_into().unwrap()
89
+ | ++++++++++++++++++++
60
90
61
91
error[E0308]: mismatched types
62
92
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:53:13
63
93
|
64
94
LL | fn cat() -> impl std::fmt::Display {
65
- | ---------------------- expected `_ ` because of return type
95
+ | ---------------------- expected `i32 ` because of return type
66
96
...
67
97
LL | 1u32
68
98
| ^^^^ expected `i32`, found `u32`
99
+ |
100
+ help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
101
+ |
102
+ LL | }.try_into().unwrap()
103
+ | ++++++++++++++++++++
69
104
70
105
error[E0308]: `match` arms have incompatible types
71
106
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:61:14
@@ -78,6 +113,11 @@ LL | | 1 => 1u32,
78
113
LL | | _ => 2u32,
79
114
LL | | }
80
115
| |_____- `match` arms have incompatible types
116
+ |
117
+ help: change the type of the numeric literal from `u32` to `i32`
118
+ |
119
+ LL | 1 => 1i32,
120
+ | ~~~
81
121
82
122
error[E0308]: `if` and `else` have incompatible types
83
123
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:97:9
@@ -90,6 +130,11 @@ LL | | 1u32
90
130
| | ^^^^ expected `i32`, found `u32`
91
131
LL | | }
92
132
| |_____- `if` and `else` have incompatible types
133
+ |
134
+ help: change the type of the numeric literal from `u32` to `i32`
135
+ |
136
+ LL | 1i32
137
+ | ~~~
93
138
94
139
error[E0746]: return type cannot have an unboxed trait object
95
140
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13
@@ -125,6 +170,11 @@ LL | | 1 => 1u32,
125
170
LL | | _ => 2u32,
126
171
LL | | }
127
172
| |_____- `match` arms have incompatible types
173
+ |
174
+ help: change the type of the numeric literal from `u32` to `i32`
175
+ |
176
+ LL | 1 => 1i32,
177
+ | ~~~
128
178
129
179
error[E0746]: return type cannot have an unboxed trait object
130
180
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13
@@ -164,6 +214,11 @@ LL | | 1u32
164
214
| | ^^^^ expected `i32`, found `u32`
165
215
LL | | }
166
216
| |_____- `if` and `else` have incompatible types
217
+ |
218
+ help: change the type of the numeric literal from `u32` to `i32`
219
+ |
220
+ LL | 1i32
221
+ | ~~~
167
222
168
223
error[E0746]: return type cannot have an unboxed trait object
169
224
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13
0 commit comments