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 this return type...
8 | ---- ...is found to be `i32` here
11 | ^^^^ expected `i32`, found `u32`
13 = note: to return `impl Trait`, all returned values must be of the same type
14 = help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
15 = help: alternatively, create a new `enum` with a variant for each returned type
16 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
17 = 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>
19 error[E0308]: mismatched types
20 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:13:16
22 LL | fn bar() -> impl std::fmt::Display {
23 | ---------------------- expected because this return type...
26 | ---- ...is found to be `i32` here
29 | ^^^^ expected `i32`, found `u32`
31 = note: to return `impl Trait`, all returned values must be of the same type
32 = help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
33 = help: alternatively, create a new `enum` with a variant for each returned type
34 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
35 = 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>
37 error[E0308]: mismatched types
38 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:22:9
40 LL | fn baz() -> impl std::fmt::Display {
41 | ---------------------- expected because this return type...
44 | ---- ...is found to be `i32` here
47 | ^^^^ expected `i32`, found `u32`
49 = note: to return `impl Trait`, all returned values must be of the same type
50 = help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
51 = help: alternatively, create a new `enum` with a variant for each returned type
52 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
53 = 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>
55 error[E0308]: `if` and `else` have incompatible types
56 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:31:9
60 | | ---- expected because of this
63 | | ^^^^ expected `i32`, found `u32`
66 | |_____- `if` and `else` have incompatible types
68 error[E0308]: mismatched types
69 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:39:14
71 LL | fn bat() -> impl std::fmt::Display {
72 | ---------------------- expected because this return type...
74 LL | 0 => return 0i32,
75 | ---- ...is found to be `i32` here
77 | ^^^^ expected `i32`, found `u32`
79 = note: to return `impl Trait`, all returned values must be of the same type
80 = help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
81 = help: alternatively, create a new `enum` with a variant for each returned type
82 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
83 = 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>
85 error[E0308]: mismatched types
86 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:45:5
88 LL | fn can() -> impl std::fmt::Display {
89 | ---------------------- expected because this return type...
92 LL | | 0 => return 0i32,
93 | | ---- ...is found to be `i32` here
97 | |_____^ expected `i32`, found `u32`
99 = note: to return `impl Trait`, all returned values must be of the same type
100 = help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
101 = help: alternatively, create a new `enum` with a variant for each returned 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: 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>
105 error[E0308]: mismatched types
106 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:59:13
108 LL | fn cat() -> impl std::fmt::Display {
109 | ---------------------- expected because this return type...
112 | ---- ...is found to be `i32` here
115 | ^^^^ expected `i32`, found `u32`
117 = note: to return `impl Trait`, all returned values must be of the same type
118 = help: you can instead return a trait object using `Box<dyn std::fmt::Display>`
119 = help: alternatively, create a new `enum` with a variant for each returned type
120 = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
121 = 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>
123 error: aborting due to 7 previous errors
125 For more information about this error, try `rustc --explain E0308`.