@@ -3415,8 +3415,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
3415
3415
if let Some ( suggested_field_name) =
3416
3416
Self :: suggest_field_name ( def. non_enum_variant ( ) ,
3417
3417
& 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
+ ) ;
3420
3424
} else {
3421
3425
err. span_label ( field. span , "unknown field" ) ;
3422
3426
let struct_variant_def = def. non_enum_variant ( ) ;
@@ -3543,8 +3547,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
3543
3547
if let Some ( field_name) = Self :: suggest_field_name ( variant,
3544
3548
& field. ident . as_str ( ) ,
3545
3549
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
+ ) ;
3548
3556
} else {
3549
3557
match ty. sty {
3550
3558
ty:: Adt ( adt, ..) => {
@@ -5257,13 +5265,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5257
5265
if let Some ( adt_def) = adt_def {
5258
5266
match adt_def. adt_kind ( ) {
5259
5267
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?" ) ;
5261
5269
} ,
5262
5270
AdtKind :: Struct |
5263
5271
AdtKind :: Union => {
5264
- err. span_label (
5272
+ err. span_suggestion_with_applicability (
5265
5273
span,
5266
- format ! ( "did you mean `Self {{ /* fields */ }}`?" ) ,
5274
+ "use curly brackets" ,
5275
+ String :: from ( "Self { /* fields */ }" ) ,
5276
+ Applicability :: HasPlaceholders ,
5267
5277
) ;
5268
5278
}
5269
5279
}
0 commit comments