]> git.proxmox.com Git - rustc.git/blob - src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr
New upstream version 1.62.1+dfsg1
[rustc.git] / src / test / ui / impl-trait / 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 of return type
6 ...
7 LL | 1u32
8 | ^^^^ expected `i32`, found `u32`
9
10 error[E0308]: mismatched types
11 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:12:16
12 |
13 LL | fn bar() -> impl std::fmt::Display {
14 | ---------------------- expected `_` because of return type
15 ...
16 LL | return 1u32;
17 | ^^^^ expected `i32`, found `u32`
18
19 error[E0308]: mismatched types
20 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:20:9
21 |
22 LL | fn baz() -> impl std::fmt::Display {
23 | ---------------------- expected `_` because of return type
24 ...
25 LL | 1u32
26 | ^^^^ expected `i32`, found `u32`
27
28 error[E0308]: `if` and `else` have incompatible types
29 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:28:9
30 |
31 LL | / if false {
32 LL | | 0i32
33 | | ---- expected because of this
34 LL | | } else {
35 LL | | 1u32
36 | | ^^^^ expected `i32`, found `u32`
37 LL | | }
38 | |_____- `if` and `else` have incompatible types
39
40 error[E0308]: mismatched types
41 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:35:14
42 |
43 LL | fn bat() -> impl std::fmt::Display {
44 | ---------------------- expected `_` because of return type
45 ...
46 LL | _ => 1u32,
47 | ^^^^ expected `i32`, found `u32`
48
49 error[E0308]: mismatched types
50 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:40:5
51 |
52 LL | fn can() -> impl std::fmt::Display {
53 | ---------------------- expected `_` because of return type
54 LL | / match 13 {
55 LL | | 0 => return 0i32,
56 LL | | 1 => 1u32,
57 LL | | _ => 2u32,
58 LL | | }
59 | |_____^ expected `i32`, found `u32`
60
61 error[E0308]: mismatched types
62 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:53:13
63 |
64 LL | fn cat() -> impl std::fmt::Display {
65 | ---------------------- expected `_` because of return type
66 ...
67 LL | 1u32
68 | ^^^^ expected `i32`, found `u32`
69
70 error[E0308]: `match` arms have incompatible types
71 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:61:14
72 |
73 LL | / match 13 {
74 LL | | 0 => 0i32,
75 | | ---- this is found to be of type `i32`
76 LL | | 1 => 1u32,
77 | | ^^^^ expected `i32`, found `u32`
78 LL | | _ => 2u32,
79 LL | | }
80 | |_____- `match` arms have incompatible types
81
82 error[E0308]: `if` and `else` have incompatible types
83 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:97:9
84 |
85 LL | / if let Some(42) = Some(42) {
86 LL | | 0i32
87 | | ---- expected because of this
88 LL | | } else {
89 LL | | 1u32
90 | | ^^^^ expected `i32`, found `u32`
91 LL | | }
92 | |_____- `if` and `else` have incompatible types
93
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
96 |
97 LL | fn hat() -> dyn std::fmt::Display {
98 | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
99 |
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
105 |
106 LL | fn hat() -> Box<dyn std::fmt::Display> {
107 | ++++ +
108 help: ... and box this value
109 |
110 LL | return Box::new(0i32);
111 | +++++++++ +
112 help: ... and box this value
113 |
114 LL | Box::new(1u32)
115 | +++++++++ +
116
117 error[E0308]: `match` arms have incompatible types
118 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:80:14
119 |
120 LL | / match 13 {
121 LL | | 0 => 0i32,
122 | | ---- this is found to be of type `i32`
123 LL | | 1 => 1u32,
124 | | ^^^^ expected `i32`, found `u32`
125 LL | | _ => 2u32,
126 LL | | }
127 | |_____- `match` arms have incompatible types
128
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
131 |
132 LL | fn pug() -> dyn std::fmt::Display {
133 | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
134 |
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
140 |
141 LL | fn pug() -> Box<dyn std::fmt::Display> {
142 | ++++ +
143 help: ... and box this value
144 |
145 LL | 0 => Box::new(0i32),
146 | +++++++++ +
147 help: ... and box this value
148 |
149 LL | 1 => Box::new(1u32),
150 | +++++++++ +
151 help: ... and box this value
152 |
153 LL | _ => Box::new(2u32),
154 | +++++++++ +
155
156 error[E0308]: `if` and `else` have incompatible types
157 --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:89:9
158 |
159 LL | / if false {
160 LL | | 0i32
161 | | ---- expected because of this
162 LL | | } else {
163 LL | | 1u32
164 | | ^^^^ expected `i32`, found `u32`
165 LL | | }
166 | |_____- `if` and `else` have incompatible types
167
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
170 |
171 LL | fn man() -> dyn std::fmt::Display {
172 | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
173 |
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
179 |
180 LL | fn man() -> Box<dyn std::fmt::Display> {
181 | ++++ +
182 help: ... and box this value
183 |
184 LL | Box::new(0i32)
185 | +++++++++ +
186 help: ... and box this value
187 |
188 LL | Box::new(1u32)
189 | +++++++++ +
190
191 error: aborting due to 14 previous errors
192
193 Some errors have detailed explanations: E0308, E0746.
194 For more information about an error, try `rustc --explain E0308`.