summaryrefslogtreecommitdiffstats
path: root/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr
blob: 9205d74504f6f2d6c43e77213cc7338d66909709 (plain)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5
   |
LL | fn foo() -> impl std::fmt::Display {
   |             ---------------------- expected `i32` because of return type
...
LL |     1u32
   |     ^^^^ expected `i32`, found `u32`
   |
help: change the type of the numeric literal from `u32` to `i32`
   |
LL |     1i32
   |      ~~~

error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:12:16
   |
LL | fn bar() -> impl std::fmt::Display {
   |             ---------------------- expected `i32` because of return type
...
LL |         return 1u32;
   |                ^^^^ expected `i32`, found `u32`
   |
help: change the type of the numeric literal from `u32` to `i32`
   |
LL |         return 1i32;
   |                 ~~~

error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:20:9
   |
LL | fn baz() -> impl std::fmt::Display {
   |             ---------------------- expected `i32` because of return type
...
LL |         1u32
   |         ^^^^ expected `i32`, found `u32`
   |
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
   |
LL |     }.try_into().unwrap()
   |      ++++++++++++++++++++

error[E0308]: `if` and `else` have incompatible types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:28:9
   |
LL | /     if false {
LL | |         0i32
   | |         ---- expected because of this
LL | |     } else {
LL | |         1u32
   | |         ^^^^ expected `i32`, found `u32`
LL | |     }
   | |_____- `if` and `else` have incompatible types
   |
help: you could change the return type to be a boxed trait object
   |
LL | fn qux() -> Box<dyn std::fmt::Display> {
   |             ~~~~~~~                  +
help: if you change the return type to expect trait objects, box the returned expressions
   |
LL ~         Box::new(0i32)
LL |     } else {
LL ~         Box::new(1u32)
   |
help: change the type of the numeric literal from `u32` to `i32`
   |
LL |         1i32
   |          ~~~

error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:35:14
   |
LL | fn bat() -> impl std::fmt::Display {
   |             ---------------------- expected `i32` because of return type
...
LL |         _ => 1u32,
   |              ^^^^ expected `i32`, found `u32`
   |
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
   |
LL |     }.try_into().unwrap()
   |      ++++++++++++++++++++

error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:40:5
   |
LL |   fn can() -> impl std::fmt::Display {
   |               ---------------------- expected `i32` because of return type
LL | /     match 13 {
LL | |         0 => return 0i32,
LL | |         1 => 1u32,
LL | |         _ => 2u32,
LL | |     }
   | |_____^ expected `i32`, found `u32`
   |
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
   |
LL |     }.try_into().unwrap()
   |      ++++++++++++++++++++

error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:53:13
   |
LL | fn cat() -> impl std::fmt::Display {
   |             ---------------------- expected `i32` because of return type
...
LL |             1u32
   |             ^^^^ expected `i32`, found `u32`
   |
help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
   |
LL |     }.try_into().unwrap()
   |      ++++++++++++++++++++

error[E0308]: `match` arms have incompatible types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:61:14
   |
LL | /     match 13 {
LL | |         0 => 0i32,
   | |              ---- this is found to be of type `i32`
LL | |         1 => 1u32,
   | |              ^^^^ expected `i32`, found `u32`
LL | |         _ => 2u32,
LL | |     }
   | |_____- `match` arms have incompatible types
   |
help: you could change the return type to be a boxed trait object
   |
LL | fn dog() -> Box<dyn std::fmt::Display> {
   |             ~~~~~~~                  +
help: if you change the return type to expect trait objects, box the returned expressions
   |
LL ~         0 => Box::new(0i32),
LL ~         1 => Box::new(1u32),
   |
help: change the type of the numeric literal from `u32` to `i32`
   |
LL |         1 => 1i32,
   |               ~~~

error[E0308]: `if` and `else` have incompatible types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:97:9
   |
LL | /     if let Some(42) = Some(42) {
LL | |         0i32
   | |         ---- expected because of this
LL | |     } else {
LL | |         1u32
   | |         ^^^^ expected `i32`, found `u32`
LL | |     }
   | |_____- `if` and `else` have incompatible types
   |
help: you could change the return type to be a boxed trait object
   |
LL | fn apt() -> Box<dyn std::fmt::Display> {
   |             ~~~~~~~                  +
help: if you change the return type to expect trait objects, box the returned expressions
   |
LL ~         Box::new(0i32)
LL |     } else {
LL ~         Box::new(1u32)
   |
help: change the type of the numeric literal from `u32` to `i32`
   |
LL |         1i32
   |          ~~~

error[E0746]: return type cannot have an unboxed trait object
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13
   |
LL | fn hat() -> dyn std::fmt::Display {
   |             ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type
   |
LL | fn hat() -> impl std::fmt::Display {
   |             ~~~~
help: box the return type, and wrap all of the returned values in `Box::new`
   |
LL ~ fn hat() -> Box<dyn std::fmt::Display> {
LL |     match 13 {
LL |         0 => {
LL ~             return Box::new(0i32);
LL |         }
LL |         _ => {
LL ~             Box::new(1u32)
   |

error[E0746]: return type cannot have an unboxed trait object
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13
   |
LL | fn pug() -> dyn std::fmt::Display {
   |             ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type
   |
LL | fn pug() -> impl std::fmt::Display {
   |             ~~~~
help: box the return type, and wrap all of the returned values in `Box::new`
   |
LL ~ fn pug() -> Box<dyn std::fmt::Display> {
LL |     match 13 {
LL ~         0 => Box::new(0i32),
LL ~         1 => Box::new(1u32),
LL ~         _ => Box::new(2u32),
   |

error[E0746]: return type cannot have an unboxed trait object
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13
   |
LL | fn man() -> dyn std::fmt::Display {
   |             ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type
   |
LL | fn man() -> impl std::fmt::Display {
   |             ~~~~
help: box the return type, and wrap all of the returned values in `Box::new`
   |
LL ~ fn man() -> Box<dyn std::fmt::Display> {
LL |     if false {
LL ~         Box::new(0i32)
LL |     } else {
LL ~         Box::new(1u32)
   |

error: aborting due to 12 previous errors

Some errors have detailed explanations: E0308, E0746.
For more information about an error, try `rustc --explain E0308`.