1 error[E0308]: mismatched types
2 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5
4 LL | fn foo() -> impl std::fmt::Display {
5 | ---------------------- expected `i32` because of return type
8 | ^^^^ expected `i32`, found `u32`
10 help: change the type of the numeric literal from `u32` to `i32`
15 error[E0308]: mismatched types
16 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:12:16
18 LL | fn bar() -> impl std::fmt::Display {
19 | ---------------------- expected `i32` because of return type
22 | ^^^^ expected `i32`, found `u32`
24 help: change the type of the numeric literal from `u32` to `i32`
29 error[E0308]: mismatched types
30 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:20:9
32 LL | fn baz() -> impl std::fmt::Display {
33 | ---------------------- expected `i32` because of return type
36 | ^^^^ expected `i32`, found `u32`
38 help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
40 LL | }.try_into().unwrap()
41 | ++++++++++++++++++++
43 error[E0308]: `if` and `else` have incompatible types
44 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:28:9
48 | | ---- expected because of this
51 | | ^^^^ expected `i32`, found `u32`
53 | |_____- `if` and `else` have incompatible types
55 help: you could change the return type to be a boxed trait object
57 LL | fn qux() -> Box<dyn std::fmt::Display> {
59 help: if you change the return type to expect trait objects, box the returned expressions
65 help: change the type of the numeric literal from `u32` to `i32`
70 error[E0308]: mismatched types
71 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:35:14
73 LL | fn bat() -> impl std::fmt::Display {
74 | ---------------------- expected `i32` because of return type
77 | ^^^^ expected `i32`, found `u32`
79 help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
81 LL | }.try_into().unwrap()
82 | ++++++++++++++++++++
84 error[E0308]: mismatched types
85 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:40:5
87 LL | fn can() -> impl std::fmt::Display {
88 | ---------------------- expected `i32` because of return type
90 LL | | 0 => return 0i32,
94 | |_____^ expected `i32`, found `u32`
96 help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
98 LL | }.try_into().unwrap()
99 | ++++++++++++++++++++
101 error[E0308]: mismatched types
102 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:53:13
104 LL | fn cat() -> impl std::fmt::Display {
105 | ---------------------- expected `i32` because of return type
108 | ^^^^ expected `i32`, found `u32`
110 help: you can convert a `u32` to an `i32` and panic if the converted value doesn't fit
112 LL | }.try_into().unwrap()
113 | ++++++++++++++++++++
115 error[E0308]: `match` arms have incompatible types
116 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:61:14
120 | | ---- this is found to be of type `i32`
122 | | ^^^^ expected `i32`, found `u32`
125 | |_____- `match` arms have incompatible types
127 help: you could change the return type to be a boxed trait object
129 LL | fn dog() -> Box<dyn std::fmt::Display> {
131 help: if you change the return type to expect trait objects, box the returned expressions
133 LL ~ 0 => Box::new(0i32),
134 LL ~ 1 => Box::new(1u32),
136 help: change the type of the numeric literal from `u32` to `i32`
141 error[E0308]: `if` and `else` have incompatible types
142 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:97:9
144 LL | / if let Some(42) = Some(42) {
146 | | ---- expected because of this
149 | | ^^^^ expected `i32`, found `u32`
151 | |_____- `if` and `else` have incompatible types
153 help: you could change the return type to be a boxed trait object
155 LL | fn apt() -> Box<dyn std::fmt::Display> {
157 help: if you change the return type to expect trait objects, box the returned expressions
163 help: change the type of the numeric literal from `u32` to `i32`
168 error[E0746]: return type cannot have an unboxed trait object
169 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13
171 LL | fn hat() -> dyn std::fmt::Display {
172 | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
174 = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
175 = note: if all the returned values were of the same type you could use `impl std::fmt::Display` as the return type
176 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
177 = note: you can create a new `enum` with a variant for each returned type
178 help: return a boxed trait object instead
180 LL | fn hat() -> Box<dyn std::fmt::Display> {
182 help: ... and box this value
184 LL | return Box::new(0i32);
186 help: ... and box this value
191 error[E0308]: `match` arms have incompatible types
192 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:80:14
196 | | ---- this is found to be of type `i32`
198 | | ^^^^ expected `i32`, found `u32`
201 | |_____- `match` arms have incompatible types
203 help: change the type of the numeric literal from `u32` to `i32`
208 error[E0746]: return type cannot have an unboxed trait object
209 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13
211 LL | fn pug() -> dyn std::fmt::Display {
212 | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
214 = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
215 = note: if all the returned values were of the same type you could use `impl std::fmt::Display` as the return type
216 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
217 = note: you can create a new `enum` with a variant for each returned type
218 help: return a boxed trait object instead
220 LL | fn pug() -> Box<dyn std::fmt::Display> {
222 help: ... and box this value
224 LL | 0 => Box::new(0i32),
226 help: ... and box this value
228 LL | 1 => Box::new(1u32),
230 help: ... and box this value
232 LL | _ => Box::new(2u32),
235 error[E0308]: `if` and `else` have incompatible types
236 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:89:9
240 | | ---- expected because of this
243 | | ^^^^ expected `i32`, found `u32`
245 | |_____- `if` and `else` have incompatible types
247 help: change the type of the numeric literal from `u32` to `i32`
252 error[E0746]: return type cannot have an unboxed trait object
253 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13
255 LL | fn man() -> dyn std::fmt::Display {
256 | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
258 = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
259 = note: if all the returned values were of the same type you could use `impl std::fmt::Display` as the return type
260 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
261 = note: you can create a new `enum` with a variant for each returned type
262 help: return a boxed trait object instead
264 LL | fn man() -> Box<dyn std::fmt::Display> {
266 help: ... and box this value
270 help: ... and box this value
275 error: aborting due to 14 previous errors
277 Some errors have detailed explanations: E0308, E0746.
278 For more information about an error, try `rustc --explain E0308`.