1 error[E0308]: mismatched types
2 --> $DIR/compatible-variants.rs:13:5
4 LL | fn a() -> Option<()> {
5 | ---------- expected `Option<()>` because of return type
10 | |_____^ expected enum `Option`, found `()`
12 = note: expected enum `Option<()>`
14 help: try adding an expression at the end of the block
23 error[E0308]: mismatched types
24 --> $DIR/compatible-variants.rs:21:5
26 LL | fn b() -> Result<(), ()> {
27 | -------------- expected `Result<(), ()>` because of return type
29 | ^^^ expected enum `Result`, found `()`
31 = note: expected enum `Result<(), ()>`
33 help: try adding an expression at the end of the block
39 error[E0308]: mismatched types
40 --> $DIR/compatible-variants.rs:27:5
42 LL | fn c() -> Option<()> {
43 | ---------- expected `Option<()>` because of return type
44 LL | / for _ in [1, 2] {
48 | |_____^ expected enum `Option`, found `()`
50 = note: expected enum `Option<()>`
52 help: try adding an expression at the end of the block
61 error[E0308]: `?` operator has incompatible types
62 --> $DIR/compatible-variants.rs:35:5
65 | ^^^^ expected enum `Option`, found `()`
67 = note: `?` operator cannot convert from `()` to `Option<()>`
68 = note: expected enum `Option<()>`
70 help: try removing this `?`
75 help: try adding an expression at the end of the block
84 error[E0308]: mismatched types
85 --> $DIR/compatible-variants.rs:42:25
87 LL | let _: Option<()> = while false {};
88 | ---------- ^^^^^^^^^^^^^^ expected enum `Option`, found `()`
90 | expected due to this
92 = note: expected enum `Option<()>`
94 help: try wrapping the expression in `Some`
96 LL | let _: Option<()> = Some(while false {});
99 error[E0308]: mismatched types
100 --> $DIR/compatible-variants.rs:46:9
103 | ^^^^^^^^^^^^^^ expected enum `Option`, found `()`
105 = note: expected enum `Option<()>`
107 help: try adding an expression at the end of the block
116 error[E0308]: mismatched types
117 --> $DIR/compatible-variants.rs:50:31
119 LL | let _: Result<i32, i32> = 1;
120 | ---------------- ^ expected enum `Result`, found integer
122 | expected due to this
124 = note: expected enum `Result<i32, i32>`
125 found type `{integer}`
126 help: try wrapping the expression in a variant of `Result`
128 LL | let _: Result<i32, i32> = Ok(1);
130 LL | let _: Result<i32, i32> = Err(1);
133 error[E0308]: mismatched types
134 --> $DIR/compatible-variants.rs:53:26
136 LL | let _: Option<i32> = 1;
137 | ----------- ^ expected enum `Option`, found integer
139 | expected due to this
141 = note: expected enum `Option<i32>`
142 found type `{integer}`
143 help: try wrapping the expression in `Some`
145 LL | let _: Option<i32> = Some(1);
148 error[E0308]: mismatched types
149 --> $DIR/compatible-variants.rs:56:28
151 LL | let _: Hey<i32, i32> = 1;
152 | ------------- ^ expected enum `Hey`, found integer
154 | expected due to this
156 = note: expected enum `Hey<i32, i32>`
157 found type `{integer}`
158 help: try wrapping the expression in a variant of `Hey`
160 LL | let _: Hey<i32, i32> = Hey::A(1);
162 LL | let _: Hey<i32, i32> = Hey::B(1);
165 error[E0308]: mismatched types
166 --> $DIR/compatible-variants.rs:59:29
168 LL | let _: Hey<i32, bool> = false;
169 | -------------- ^^^^^ expected enum `Hey`, found `bool`
171 | expected due to this
173 = note: expected enum `Hey<i32, bool>`
175 help: try wrapping the expression in `Hey::B`
177 LL | let _: Hey<i32, bool> = Hey::B(false);
180 error[E0308]: mismatched types
181 --> $DIR/compatible-variants.rs:63:19
183 LL | let _ = Foo { bar };
184 | ^^^ expected enum `Option`, found `i32`
186 = note: expected enum `Option<i32>`
188 help: try wrapping the expression in `Some`
190 LL | let _ = Foo { bar: Some(bar) };
193 error[E0308]: mismatched types
194 --> $DIR/compatible-variants.rs:80:16
196 LL | let a: A = B::Fst;
197 | - ^^^^^^ expected enum `A`, found enum `B`
199 | expected due to this
201 help: try wrapping the expression in `A::B`
203 LL | let a: A = A::B { b: B::Fst };
206 error[E0308]: mismatched types
207 --> $DIR/compatible-variants.rs:86:17
209 LL | let a: A2 = B::Fst;
210 | -- ^^^^^^ expected struct `A2`, found enum `B`
212 | expected due to this
214 help: try wrapping the expression in `A2`
216 LL | let a: A2 = A2(B::Fst);
219 error: aborting due to 13 previous errors
221 For more information about this error, try `rustc --explain E0308`.