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 `_` because of return type
8 | ^^^^ expected `i32`, found `u32`
10 error[E0308]: mismatched types
11 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:12:16
13 LL | fn bar() -> impl std::fmt::Display {
14 | ---------------------- expected `_` because of return type
17 | ^^^^ expected `i32`, found `u32`
19 error[E0308]: mismatched types
20 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:20:9
22 LL | fn baz() -> impl std::fmt::Display {
23 | ---------------------- expected `_` because of return type
26 | ^^^^ expected `i32`, found `u32`
28 error[E0308]: `if` and `else` have incompatible types
29 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:28:9
33 | | ---- expected because of this
36 | | ^^^^ expected `i32`, found `u32`
38 | |_____- `if` and `else` have incompatible types
40 error[E0308]: mismatched types
41 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:35:14
43 LL | fn bat() -> impl std::fmt::Display {
44 | ---------------------- expected `_` because of return type
47 | ^^^^ expected `i32`, found `u32`
49 error[E0308]: mismatched types
50 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:40:5
52 LL | fn can() -> impl std::fmt::Display {
53 | ---------------------- expected `_` because of return type
55 LL | | 0 => return 0i32,
59 | |_____^ expected `i32`, found `u32`
61 error[E0308]: mismatched types
62 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:53:13
64 LL | fn cat() -> impl std::fmt::Display {
65 | ---------------------- expected `_` because of return type
68 | ^^^^ expected `i32`, found `u32`
70 error[E0308]: `match` arms have incompatible types
71 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:61:14
75 | | ---- this is found to be of type `i32`
77 | | ^^^^ expected `i32`, found `u32`
80 | |_____- `match` arms have incompatible types
82 error[E0308]: `if` and `else` have incompatible types
83 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:97:9
85 LL | / if let Some(42) = Some(42) {
87 | | ---- expected because of this
90 | | ^^^^ expected `i32`, found `u32`
92 | |_____- `if` and `else` have incompatible types
94 error[E0746]: return type cannot have an unboxed trait object
95 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13
97 LL | fn hat() -> dyn std::fmt::Display {
98 | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
100 = 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>
101 = note: if all the returned values were of the same type you could use `impl std::fmt::Display` as the return type
102 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
103 = note: you can create a new `enum` with a variant for each returned type
104 help: return a boxed trait object instead
106 LL | fn hat() -> Box<dyn std::fmt::Display> {
108 help: ... and box this value
110 LL | return Box::new(0i32);
112 help: ... and box this value
117 error[E0308]: `match` arms have incompatible types
118 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:80:14
122 | | ---- this is found to be of type `i32`
124 | | ^^^^ expected `i32`, found `u32`
127 | |_____- `match` arms have incompatible types
129 error[E0746]: return type cannot have an unboxed trait object
130 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13
132 LL | fn pug() -> dyn std::fmt::Display {
133 | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
135 = 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>
136 = note: if all the returned values were of the same type you could use `impl std::fmt::Display` as the return type
137 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
138 = note: you can create a new `enum` with a variant for each returned type
139 help: return a boxed trait object instead
141 LL | fn pug() -> Box<dyn std::fmt::Display> {
143 help: ... and box this value
145 LL | 0 => Box::new(0i32),
147 help: ... and box this value
149 LL | 1 => Box::new(1u32),
151 help: ... and box this value
153 LL | _ => Box::new(2u32),
156 error[E0308]: `if` and `else` have incompatible types
157 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:89:9
161 | | ---- expected because of this
164 | | ^^^^ expected `i32`, found `u32`
166 | |_____- `if` and `else` have incompatible types
168 error[E0746]: return type cannot have an unboxed trait object
169 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13
171 LL | fn man() -> 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 man() -> Box<dyn std::fmt::Display> {
182 help: ... and box this value
186 help: ... and box this value
191 error: aborting due to 14 previous errors
193 Some errors have detailed explanations: E0308, E0746.
194 For more information about an error, try `rustc --explain E0308`.