Change:
Consider the following code (): It currently yields the following diagnostic messages: This line is what I object to: It has two problems: It uses the terminology when discussing building up an instance of the struct . It uses a tuple struct form in the example rewrite it provides; but our is a braced struct with named fields.
Is GitHub suffering from some kind of cache-consistency problem!? (I guess so: they're investigating service unavailability.) I apparently-successfully opened PR to fix this, but then it wasn't showing up in the and the pull/ URL was 404ing, so then I thought that it might not have actually gone through, so then I tried to resubmit, and then that failed with an "A pull request already exists" flash message, and then I wanted to try submitting under a different branch name, and/or rebased so as to have a different SHA (on the theory that maybe the problem had something to do with the fact that I was reusing the branch name from the my PR of last year in which the "variant of the expected type" message was introduced, even though it would be really surprising if a site as old and usually-stable as GitHub didn't already handle that case), but then the "Compare branches" pages aren't showing the open-pull-request form that they usually do. Typically I wouldn't even bother commenting about this kind of glitch (trusting that our friends at GitHub will sort it out any mere availability issue soon enough), but the fact that other PR pages are loading fine for me makes me wonder if there's some kind of bad state associated with in particular?!
Is GitHub suffering from some kind of cache-consistency problem!? (I guess so: they're investigating service unavailability.) I apparently-successfully opened PR to fix this, but then it wasn't showing up in the and the pull/ URL was 404ing, so then I thought that it might not have actually gone through, so then I tried to resubmit, and then that failed with an "A pull request already exists" flash message, and then I wanted to try submitting under a different branch name, and/or rebased so as to have a different SHA (on the theory that maybe the problem had something to do with the fact that I was reusing the branch name from the my PR of last year in which the "variant of the expected type" message was introduced, even though it would be really surprising if a site as old and usually-stable as GitHub didn't already handle that case), but then the "Compare branches" pages aren't showing the open-pull-request form that they usually do. Typically I wouldn't even bother commenting about this kind of glitch (trusting that our friends at GitHub will sort it out any mere availability issue soon enough), but the fact that other PR pages are loading fine for me makes me wonder if there's some kind of bad state associated with in particular?!

Discussion:
let expr_ty = self.resolve_type_vars_with_obligations(checked_ty); let mut err = self.report_mismatched_types(&cause, expected, expr_ty, e); <del> // If the expected type is an enum with any variants whose sole // field is of the found type, suggest such variants. See Issue // #42764. </del> <ins> // If the expected type is an enum (Issue #55250) with any variants whose // sole field is of the found type, suggest such variants. (Issue #42764) </ins> if let ty::Adt(expected_adt, substs) = expected.sty { <del> let mut compatible_variants = expected_adt.variants .iter() .filter(|variant| variant.fields.len() == 1) .filter_map(|variant| { let sole_field = &variant.fields[0]; let sole_field_ty = sole_field.ty(self.tcx, substs); if self.can_coerce(expr_ty, sole_field_ty) { let variant_path = self.tcx.item_path_str(variant.did); Some(variant_path.trim_left_matches("std::prelude::v1::").to_string()) } else { None </del> <ins> if expected_adt.is_enum() { let mut compatible_variants = expected_adt.variants .iter() .filter(|variant| variant.fields.len() == 1) .filter_map(|variant| { let sole_field = &variant.fields[0]; let sole_field_ty = sole_field.ty(self.tcx, substs); if self.can_coerce(expr_ty, sole_field_ty) { let variant_path = self.tcx.item_path_str(variant.did); Some(variant_path.trim_left_matches("std::prelude::v1::").to_string()) } else { None } }).peekable(); if compatible_variants.peek().is_some() { let expr_text = print::to_string(print::NO_ANN, |s| s.print_expr(expr)); let suggestions = compatible_variants .map(|v| format!("{}({})", v, expr_text)).collect::<Vec<_>>(); err.span_suggestions_with_applicability( expr.span, "try using a variant of the expected type", suggestions, Applicability::MaybeIncorrect, ); </ins> } <del> }).peekable(); if compatible_variants.peek().is_some() { let expr_text = print::to_string(print::NO_ANN, |s| s.print_expr(expr)); let suggestions = compatible_variants.map(|v| format!("{}({})", v, expr_text)).collect::<Vec<_>>(); err.span_suggestions_with_applicability( expr.span, "try using a variant of the expected type", suggestions, Applicability::MaybeIncorrect, ); </del> } }

let n: usize = 42; this_function_expects_a_double_option(n); //~^ ERROR mismatched types <ins> //~| HELP try using a variant of the expected type } // But don't issue the "try using a variant" help if the one-"variant" ADT is // actually a one-field struct. struct Payload; struct Wrapper { payload: Payload } struct Context { wrapper: Wrapper } fn overton() { let _c = Context { wrapper: Payload{} }; //~^ ERROR mismatched types </ins> }

LL |     this_function_expects_a_double_option(DoubleOption::AlternativeSome(n)); |                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <del> error: aborting due to previous error </del> <ins> error[E0308]: mismatched types --> $DIR/issue-42764.rs:37:33 | LL |     let _c = Context { wrapper: Payload{} }; |                                 ^^^^^^^^^ expected struct `Wrapper`, found struct `Payload` | = note: expected type `Wrapper` found type `Payload` error: aborting due to 2 previous errors </ins> For more information about this error, try `rustc --explain E0308`.