]> git.lizzy.rs Git - rust.git/blob - src/test/ui/point-to-type-err-cause-on-impl-trait-return.stderr
Rollup merge of #67734 - XAMPPRocky:master, r=skade
[rust.git] / src / test / ui / point-to-type-err-cause-on-impl-trait-return.stderr
1 error[E0308]: mismatched types
2   --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5
3    |
4 LL | fn foo() -> impl std::fmt::Display {
5    |             ---------------------- expected because this return type...
6 LL |     if false {
7 LL |         return 0i32;
8    |                ---- ...is found to be `i32` here
9 LL |     }
10 LL |     1u32
11    |     ^^^^ expected `i32`, found `u32`
12    |
13    = note: to return `impl Trait`, all returned values must be of the same type
14    = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
15    = help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
16    = 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>
17    = help: alternatively, create a new `enum` with a variant for each returned type
18
19 error[E0308]: mismatched types
20   --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:13:16
21    |
22 LL | fn bar() -> impl std::fmt::Display {
23    |             ---------------------- expected because this return type...
24 LL |     if false {
25 LL |         return 0i32;
26    |                ---- ...is found to be `i32` here
27 LL |     } else {
28 LL |         return 1u32;
29    |                ^^^^ expected `i32`, found `u32`
30    |
31    = note: to return `impl Trait`, all returned values must be of the same type
32    = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
33    = help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
34    = 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>
35    = help: alternatively, create a new `enum` with a variant for each returned type
36
37 error[E0308]: mismatched types
38   --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:22:9
39    |
40 LL | fn baz() -> impl std::fmt::Display {
41    |             ---------------------- expected because this return type...
42 LL |     if false {
43 LL |         return 0i32;
44    |                ---- ...is found to be `i32` here
45 LL |     } else {
46 LL |         1u32
47    |         ^^^^ expected `i32`, found `u32`
48    |
49    = note: to return `impl Trait`, all returned values must be of the same type
50    = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
51    = help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
52    = 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>
53    = help: alternatively, create a new `enum` with a variant for each returned type
54
55 error[E0308]: `if` and `else` have incompatible types
56   --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:31:9
57    |
58 LL | /     if false {
59 LL | |         0i32
60    | |         ---- expected because of this
61 LL | |     } else {
62 LL | |         1u32
63    | |         ^^^^ expected `i32`, found `u32`
64 LL | |
65 LL | |     }
66    | |_____- `if` and `else` have incompatible types
67
68 error[E0308]: mismatched types
69   --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:39:14
70    |
71 LL | fn bat() -> impl std::fmt::Display {
72    |             ---------------------- expected because this return type...
73 LL |     match 13 {
74 LL |         0 => return 0i32,
75    |                     ---- ...is found to be `i32` here
76 LL |         _ => 1u32,
77    |              ^^^^ expected `i32`, found `u32`
78    |
79    = note: to return `impl Trait`, all returned values must be of the same type
80    = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
81    = help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
82    = 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>
83    = help: alternatively, create a new `enum` with a variant for each returned type
84
85 error[E0308]: mismatched types
86   --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:45:5
87    |
88 LL |   fn can() -> impl std::fmt::Display {
89    |               ---------------------- expected because this return type...
90 LL | /     match 13 {
91 LL | |
92 LL | |         0 => return 0i32,
93    | |                     ---- ...is found to be `i32` here
94 LL | |         1 => 1u32,
95 LL | |         _ => 2u32,
96 LL | |     }
97    | |_____^ expected `i32`, found `u32`
98    |
99    = note: to return `impl Trait`, all returned values must be of the same type
100    = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
101    = help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
102    = 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>
103    = help: alternatively, create a new `enum` with a variant for each returned type
104
105 error[E0308]: mismatched types
106   --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:59:13
107    |
108 LL | fn cat() -> impl std::fmt::Display {
109    |             ---------------------- expected because this return type...
110 ...
111 LL |             return 0i32;
112    |                    ---- ...is found to be `i32` here
113 ...
114 LL |             1u32
115    |             ^^^^ expected `i32`, found `u32`
116    |
117    = note: to return `impl Trait`, all returned values must be of the same type
118    = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
119    = help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
120    = 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>
121    = help: alternatively, create a new `enum` with a variant for each returned type
122
123 error: aborting due to 7 previous errors
124
125 For more information about this error, try `rustc --explain E0308`.