let compatible_variants: Vec<String> = expected_adt
.variants()
.iter()
- .filter(|variant| variant.fields.len() == 1)
+ .filter(|variant| {
+ variant.fields.len() == 1 && variant.ctor_kind == hir::def::CtorKind::Fn
+ })
.filter_map(|variant| {
let sole_field = &variant.fields[0];
let sole_field_ty = sole_field.ty(self.tcx, substs);
//~^ ERROR mismatched types
//~| HELP try wrapping
}
+
+enum A {
+ B { b: B},
+}
+
+enum B {
+ Fst,
+ Snd,
+}
+
+fn foo() {
+ // We don't want to suggest `A::B(B::Fst)` here.
+ let a: A = B::Fst;
+ //~^ ERROR mismatched types
+}
\ No newline at end of file
LL | let _ = Foo { bar: Some(bar) };
| ++++++++++ +
-error: aborting due to 11 previous errors
+error[E0308]: mismatched types
+ --> $DIR/compatible-variants.rs:79:16
+ |
+LL | let a: A = B::Fst;
+ | - ^^^^^^ expected enum `A`, found enum `B`
+ | |
+ | expected due to this
+
+error: aborting due to 12 previous errors
For more information about this error, try `rustc --explain E0308`.