]> git.lizzy.rs Git - rust.git/blob - tests/ui/did_you_mean/compatible-variants.stderr
Rollup merge of #104965 - zacklukem:p-option-as_ref-docs, r=scottmcm
[rust.git] / tests / ui / did_you_mean / compatible-variants.stderr
1 error[E0308]: mismatched types
2   --> $DIR/compatible-variants.rs:13:5
3    |
4 LL |   fn a() -> Option<()> {
5    |             ---------- expected `Option<()>` because of return type
6 LL | /     while false {
7 LL | |
8 LL | |         f();
9 LL | |     }
10    | |_____^ expected enum `Option`, found `()`
11    |
12    = note:   expected enum `Option<()>`
13            found unit type `()`
14 help: try adding an expression at the end of the block
15    |
16 LL ~     }
17 LL +     None
18    |
19 LL ~     }
20 LL +     Some(())
21    |
22
23 error[E0308]: mismatched types
24   --> $DIR/compatible-variants.rs:21:5
25    |
26 LL | fn b() -> Result<(), ()> {
27    |           -------------- expected `Result<(), ()>` because of return type
28 LL |     f()
29    |     ^^^ expected enum `Result`, found `()`
30    |
31    = note:   expected enum `Result<(), ()>`
32            found unit type `()`
33 help: try adding an expression at the end of the block
34    |
35 LL ~     f();
36 LL +     Ok(())
37    |
38
39 error[E0308]: mismatched types
40   --> $DIR/compatible-variants.rs:27:5
41    |
42 LL |   fn c() -> Option<()> {
43    |             ---------- expected `Option<()>` because of return type
44 LL | /     for _ in [1, 2] {
45 LL | |
46 LL | |         f();
47 LL | |     }
48    | |_____^ expected enum `Option`, found `()`
49    |
50    = note:   expected enum `Option<()>`
51            found unit type `()`
52 help: try adding an expression at the end of the block
53    |
54 LL ~     }
55 LL +     None
56    |
57 LL ~     }
58 LL +     Some(())
59    |
60
61 error[E0308]: `?` operator has incompatible types
62   --> $DIR/compatible-variants.rs:35:5
63    |
64 LL |     c()?
65    |     ^^^^ expected enum `Option`, found `()`
66    |
67    = note: `?` operator cannot convert from `()` to `Option<()>`
68    = note:   expected enum `Option<()>`
69            found unit type `()`
70 help: try removing this `?`
71    |
72 LL -     c()?
73 LL +     c()
74    |
75 help: try adding an expression at the end of the block
76    |
77 LL ~     c()?;
78 LL +     None
79    |
80 LL ~     c()?;
81 LL +     Some(())
82    |
83
84 error[E0308]: mismatched types
85   --> $DIR/compatible-variants.rs:42:25
86    |
87 LL |     let _: Option<()> = while false {};
88    |            ----------   ^^^^^^^^^^^^^^ expected enum `Option`, found `()`
89    |            |
90    |            expected due to this
91    |
92    = note:   expected enum `Option<()>`
93            found unit type `()`
94 help: try wrapping the expression in `Some`
95    |
96 LL |     let _: Option<()> = Some(while false {});
97    |                         +++++              +
98
99 error[E0308]: mismatched types
100   --> $DIR/compatible-variants.rs:46:9
101    |
102 LL |         while false {}
103    |         ^^^^^^^^^^^^^^ expected enum `Option`, found `()`
104    |
105    = note:   expected enum `Option<()>`
106            found unit type `()`
107 help: try adding an expression at the end of the block
108    |
109 LL ~         while false {}
110 LL +         None
111    |
112 LL ~         while false {}
113 LL +         Some(())
114    |
115
116 error[E0308]: mismatched types
117   --> $DIR/compatible-variants.rs:50:31
118    |
119 LL |     let _: Result<i32, i32> = 1;
120    |            ----------------   ^ expected enum `Result`, found integer
121    |            |
122    |            expected due to this
123    |
124    = note: expected enum `Result<i32, i32>`
125               found type `{integer}`
126 help: try wrapping the expression in a variant of `Result`
127    |
128 LL |     let _: Result<i32, i32> = Ok(1);
129    |                               +++ +
130 LL |     let _: Result<i32, i32> = Err(1);
131    |                               ++++ +
132
133 error[E0308]: mismatched types
134   --> $DIR/compatible-variants.rs:53:26
135    |
136 LL |     let _: Option<i32> = 1;
137    |            -----------   ^ expected enum `Option`, found integer
138    |            |
139    |            expected due to this
140    |
141    = note: expected enum `Option<i32>`
142               found type `{integer}`
143 help: try wrapping the expression in `Some`
144    |
145 LL |     let _: Option<i32> = Some(1);
146    |                          +++++ +
147
148 error[E0308]: mismatched types
149   --> $DIR/compatible-variants.rs:56:28
150    |
151 LL |     let _: Hey<i32, i32> = 1;
152    |            -------------   ^ expected enum `Hey`, found integer
153    |            |
154    |            expected due to this
155    |
156    = note: expected enum `Hey<i32, i32>`
157               found type `{integer}`
158 help: try wrapping the expression in a variant of `Hey`
159    |
160 LL |     let _: Hey<i32, i32> = Hey::A(1);
161    |                            +++++++ +
162 LL |     let _: Hey<i32, i32> = Hey::B(1);
163    |                            +++++++ +
164
165 error[E0308]: mismatched types
166   --> $DIR/compatible-variants.rs:59:29
167    |
168 LL |     let _: Hey<i32, bool> = false;
169    |            --------------   ^^^^^ expected enum `Hey`, found `bool`
170    |            |
171    |            expected due to this
172    |
173    = note: expected enum `Hey<i32, bool>`
174               found type `bool`
175 help: try wrapping the expression in `Hey::B`
176    |
177 LL |     let _: Hey<i32, bool> = Hey::B(false);
178    |                             +++++++     +
179
180 error[E0308]: mismatched types
181   --> $DIR/compatible-variants.rs:63:19
182    |
183 LL |     let _ = Foo { bar };
184    |                   ^^^ expected enum `Option`, found `i32`
185    |
186    = note: expected enum `Option<i32>`
187               found type `i32`
188 help: try wrapping the expression in `Some`
189    |
190 LL |     let _ = Foo { bar: Some(bar) };
191    |                   ++++++++++   +
192
193 error[E0308]: mismatched types
194   --> $DIR/compatible-variants.rs:80:16
195    |
196 LL |     let a: A = B::Fst;
197    |            -   ^^^^^^ expected enum `A`, found enum `B`
198    |            |
199    |            expected due to this
200    |
201 help: try wrapping the expression in `A::B`
202    |
203 LL |     let a: A = A::B { b: B::Fst };
204    |                +++++++++        +
205
206 error[E0308]: mismatched types
207   --> $DIR/compatible-variants.rs:86:17
208    |
209 LL |     let a: A2 = B::Fst;
210    |            --   ^^^^^^ expected struct `A2`, found enum `B`
211    |            |
212    |            expected due to this
213    |
214 help: try wrapping the expression in `A2`
215    |
216 LL |     let a: A2 = A2(B::Fst);
217    |                 +++      +
218
219 error: aborting due to 13 previous errors
220
221 For more information about this error, try `rustc --explain E0308`.