@@ -37,7 +37,52 @@ LL + Ok(())
3737 |
3838
3939error[E0308]: mismatched types
40- --> $DIR/compatible-variants.rs:27:25
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
4186 |
4287LL | let _: Option<()> = while false {};
4388 | ---------- ^^^^^^^^^^^^^^ expected enum `Option`, found `()`
@@ -52,7 +97,7 @@ LL | let _: Option<()> = Some(while false {});
5297 | +++++ +
5398
5499error[E0308]: mismatched types
55- --> $DIR/compatible-variants.rs:31 :9
100+ --> $DIR/compatible-variants.rs:46 :9
56101 |
57102LL | while false {}
58103 | ^^^^^^^^^^^^^^ expected enum `Option`, found `()`
@@ -69,7 +114,7 @@ LL + Some(())
69114 |
70115
71116error[E0308]: mismatched types
72- --> $DIR/compatible-variants.rs:35 :31
117+ --> $DIR/compatible-variants.rs:50 :31
73118 |
74119LL | let _: Result<i32, i32> = 1;
75120 | ---------------- ^ expected enum `Result`, found integer
@@ -86,7 +131,7 @@ LL | let _: Result<i32, i32> = Err(1);
86131 | ++++ +
87132
88133error[E0308]: mismatched types
89- --> $DIR/compatible-variants.rs:38 :26
134+ --> $DIR/compatible-variants.rs:53 :26
90135 |
91136LL | let _: Option<i32> = 1;
92137 | ----------- ^ expected enum `Option`, found integer
@@ -101,7 +146,7 @@ LL | let _: Option<i32> = Some(1);
101146 | +++++ +
102147
103148error[E0308]: mismatched types
104- --> $DIR/compatible-variants.rs:41 :28
149+ --> $DIR/compatible-variants.rs:56 :28
105150 |
106151LL | let _: Hey<i32, i32> = 1;
107152 | ------------- ^ expected enum `Hey`, found integer
@@ -118,7 +163,7 @@ LL | let _: Hey<i32, i32> = Hey::B(1);
118163 | +++++++ +
119164
120165error[E0308]: mismatched types
121- --> $DIR/compatible-variants.rs:44 :29
166+ --> $DIR/compatible-variants.rs:59 :29
122167 |
123168LL | let _: Hey<i32, bool> = false;
124169 | -------------- ^^^^^ expected enum `Hey`, found `bool`
@@ -133,7 +178,7 @@ LL | let _: Hey<i32, bool> = Hey::B(false);
133178 | +++++++ +
134179
135180error[E0308]: mismatched types
136- --> $DIR/compatible-variants.rs:48 :19
181+ --> $DIR/compatible-variants.rs:63 :19
137182 |
138183LL | let _ = Foo { bar };
139184 | ^^^ expected enum `Option`, found `i32`
@@ -145,6 +190,6 @@ help: try wrapping the expression in `Some`
145190LL | let _ = Foo { bar: Some(bar) };
146191 | ++++++++++ +
147192
148- error: aborting due to 9 previous errors
193+ error: aborting due to 11 previous errors
149194
150195For more information about this error, try `rustc --explain E0308`.
0 commit comments