@@ -3415,8 +3415,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
34153415 if let Some ( suggested_field_name) =
34163416 Self :: suggest_field_name ( def. non_enum_variant ( ) ,
34173417 & field. as_str ( ) , vec ! [ ] ) {
3418- err. span_label ( field. span ,
3419- format ! ( "did you mean `{}`?" , suggested_field_name) ) ;
3418+ err. span_suggestion_with_applicability (
3419+ field. span ,
3420+ "a field with a similar name exists" ,
3421+ suggested_field_name. to_string ( ) ,
3422+ Applicability :: MaybeIncorrect ,
3423+ ) ;
34203424 } else {
34213425 err. span_label ( field. span , "unknown field" ) ;
34223426 let struct_variant_def = def. non_enum_variant ( ) ;
@@ -3543,8 +3547,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
35433547 if let Some ( field_name) = Self :: suggest_field_name ( variant,
35443548 & field. ident . as_str ( ) ,
35453549 skip_fields. collect ( ) ) {
3546- err. span_label ( field. ident . span ,
3547- format ! ( "field does not exist - did you mean `{}`?" , field_name) ) ;
3550+ err. span_suggestion_with_applicability (
3551+ field. ident . span ,
3552+ "a field with a similar name exists" ,
3553+ field_name. to_string ( ) ,
3554+ Applicability :: MaybeIncorrect ,
3555+ ) ;
35483556 } else {
35493557 match ty. sty {
35503558 ty:: Adt ( adt, ..) => {
@@ -5257,13 +5265,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
52575265 if let Some ( adt_def) = adt_def {
52585266 match adt_def. adt_kind ( ) {
52595267 AdtKind :: Enum => {
5260- err. note ( "did you mean to use one of the enum's variants?" ) ;
5268+ err. help ( "did you mean to use one of the enum's variants?" ) ;
52615269 } ,
52625270 AdtKind :: Struct |
52635271 AdtKind :: Union => {
5264- err. span_label (
5272+ err. span_suggestion_with_applicability (
52655273 span,
5266- format ! ( "did you mean `Self {{ /* fields */ }}`?" ) ,
5274+ "use curly brackets" ,
5275+ String :: from ( "Self { /* fields */ }" ) ,
5276+ Applicability :: HasPlaceholders ,
52675277 ) ;
52685278 }
52695279 }
0 commit comments