@@ -3422,8 +3422,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
34223422 if let Some ( suggested_field_name) =
34233423 Self :: suggest_field_name ( def. non_enum_variant ( ) ,
34243424 & field. as_str ( ) , vec ! [ ] ) {
3425- err. span_label ( field. span ,
3426- format ! ( "did you mean `{}`?" , suggested_field_name) ) ;
3425+ err. span_suggestion_with_applicability (
3426+ field. span ,
3427+ "a field with a similar name exists" ,
3428+ suggested_field_name. to_string ( ) ,
3429+ Applicability :: MaybeIncorrect ,
3430+ ) ;
34273431 } else {
34283432 err. span_label ( field. span , "unknown field" ) ;
34293433 let struct_variant_def = def. non_enum_variant ( ) ;
@@ -3550,8 +3554,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
35503554 if let Some ( field_name) = Self :: suggest_field_name ( variant,
35513555 & field. ident . as_str ( ) ,
35523556 skip_fields. collect ( ) ) {
3553- err. span_label ( field. ident . span ,
3554- format ! ( "field does not exist - did you mean `{}`?" , field_name) ) ;
3557+ err. span_suggestion_with_applicability (
3558+ field. ident . span ,
3559+ "a field with a similar name exists" ,
3560+ field_name. to_string ( ) ,
3561+ Applicability :: MaybeIncorrect ,
3562+ ) ;
35553563 } else {
35563564 match ty. sty {
35573565 ty:: Adt ( adt, ..) => {
@@ -5195,13 +5203,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
51955203 if let Some ( adt_def) = adt_def {
51965204 match adt_def. adt_kind ( ) {
51975205 AdtKind :: Enum => {
5198- err. note ( "did you mean to use one of the enum's variants?" ) ;
5206+ err. help ( "did you mean to use one of the enum's variants?" ) ;
51995207 } ,
52005208 AdtKind :: Struct |
52015209 AdtKind :: Union => {
5202- err. span_label (
5210+ err. span_suggestion_with_applicability (
52035211 span,
5204- format ! ( "did you mean `Self {{ /* fields */ }}`?" ) ,
5212+ "use curly brackets" ,
5213+ String :: from ( "Self { /* fields */ }" ) ,
5214+ Applicability :: HasPlaceholders ,
52055215 ) ;
52065216 }
52075217 }
0 commit comments