summaryrefslogtreecommitdiffstats
path: root/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr
blob: 10510c1754eda5ca842c6d8f0d4fac312ed4b5ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5
   |
LL | fn foo() -> impl std::fmt::Display {
   |             ---------------------- expected `_` because of return type
...
LL |     1u32
   |     ^^^^ expected `i32`, found `u32`

error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:12:16
   |
LL | fn bar() -> impl std::fmt::Display {
   |             ---------------------- expected `_` because of return type
...
LL |         return 1u32;
   |                ^^^^ expected `i32`, found `u32`

error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:20:9
   |
LL | fn baz() -> impl std::fmt::Display {
   |             ---------------------- expected `_` because of return type
...
LL |         1u32
   |         ^^^^ expected `i32`, found `u32`

error[E0308]: `if` and `else` have incompatible types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:28:9
   |
LL | /     if false {
LL | |         0i32
   | |         ---- expected because of this
LL | |     } else {
LL | |         1u32
   | |         ^^^^ expected `i32`, found `u32`
LL | |     }
   | |_____- `if` and `else` have incompatible types

error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:35:14
   |
LL | fn bat() -> impl std::fmt::Display {
   |             ---------------------- expected `_` because of return type
...
LL |         _ => 1u32,
   |              ^^^^ expected `i32`, found `u32`

error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:40:5
   |
LL |   fn can() -> impl std::fmt::Display {
   |               ---------------------- expected `_` because of return type
LL | /     match 13 {
LL | |         0 => return 0i32,
LL | |         1 => 1u32,
LL | |         _ => 2u32,
LL | |     }
   | |_____^ expected `i32`, found `u32`

error[E0308]: mismatched types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:53:13
   |
LL | fn cat() -> impl std::fmt::Display {
   |             ---------------------- expected `_` because of return type
...
LL |             1u32
   |             ^^^^ expected `i32`, found `u32`

error[E0308]: `match` arms have incompatible types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:61:14
   |
LL | /     match 13 {
LL | |         0 => 0i32,
   | |              ---- this is found to be of type `i32`
LL | |         1 => 1u32,
   | |              ^^^^ expected `i32`, found `u32`
LL | |         _ => 2u32,
LL | |     }
   | |_____- `match` arms have incompatible types

error[E0308]: `if` and `else` have incompatible types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:97:9
   |
LL | /     if let Some(42) = Some(42) {
LL | |         0i32
   | |         ---- expected because of this
LL | |     } else {
LL | |         1u32
   | |         ^^^^ expected `i32`, found `u32`
LL | |     }
   | |_____- `if` and `else` have incompatible types

error[E0746]: return type cannot have an unboxed trait object
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13
   |
LL | fn hat() -> dyn std::fmt::Display {
   |             ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = 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>
   = note: if all the returned values were of the same type you could use `impl std::fmt::Display` as the return type
   = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
   = note: you can create a new `enum` with a variant for each returned type
help: return a boxed trait object instead
   |
LL | fn hat() -> Box<dyn std::fmt::Display> {
   |             ++++                     +
help: ... and box this value
   |
LL |             return Box::new(0i32);
   |                    +++++++++    +
help: ... and box this value
   |
LL |             Box::new(1u32)
   |             +++++++++    +

error[E0308]: `match` arms have incompatible types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:80:14
   |
LL | /     match 13 {
LL | |         0 => 0i32,
   | |              ---- this is found to be of type `i32`
LL | |         1 => 1u32,
   | |              ^^^^ expected `i32`, found `u32`
LL | |         _ => 2u32,
LL | |     }
   | |_____- `match` arms have incompatible types

error[E0746]: return type cannot have an unboxed trait object
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13
   |
LL | fn pug() -> dyn std::fmt::Display {
   |             ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = 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>
   = note: if all the returned values were of the same type you could use `impl std::fmt::Display` as the return type
   = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
   = note: you can create a new `enum` with a variant for each returned type
help: return a boxed trait object instead
   |
LL | fn pug() -> Box<dyn std::fmt::Display> {
   |             ++++                     +
help: ... and box this value
   |
LL |         0 => Box::new(0i32),
   |              +++++++++    +
help: ... and box this value
   |
LL |         1 => Box::new(1u32),
   |              +++++++++    +
help: ... and box this value
   |
LL |         _ => Box::new(2u32),
   |              +++++++++    +

error[E0308]: `if` and `else` have incompatible types
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:89:9
   |
LL | /     if false {
LL | |         0i32
   | |         ---- expected because of this
LL | |     } else {
LL | |         1u32
   | |         ^^^^ expected `i32`, found `u32`
LL | |     }
   | |_____- `if` and `else` have incompatible types

error[E0746]: return type cannot have an unboxed trait object
  --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13
   |
LL | fn man() -> dyn std::fmt::Display {
   |             ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = 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>
   = note: if all the returned values were of the same type you could use `impl std::fmt::Display` as the return type
   = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
   = note: you can create a new `enum` with a variant for each returned type
help: return a boxed trait object instead
   |
LL | fn man() -> Box<dyn std::fmt::Display> {
   |             ++++                     +
help: ... and box this value
   |
LL |         Box::new(0i32)
   |         +++++++++    +
help: ... and box this value
   |
LL |         Box::new(1u32)
   |         +++++++++    +

error: aborting due to 14 previous errors

Some errors have detailed explanations: E0308, E0746.
For more information about an error, try `rustc --explain E0308`.