@@ -3422,8 +3422,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
3422
3422
if let Some ( suggested_field_name) =
3423
3423
Self :: suggest_field_name ( def. non_enum_variant ( ) ,
3424
3424
& 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
+ ) ;
3427
3431
} else {
3428
3432
err. span_label ( field. span , "unknown field" ) ;
3429
3433
let struct_variant_def = def. non_enum_variant ( ) ;
@@ -3550,8 +3554,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
3550
3554
if let Some ( field_name) = Self :: suggest_field_name ( variant,
3551
3555
& field. ident . as_str ( ) ,
3552
3556
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
+ ) ;
3555
3563
} else {
3556
3564
match ty. sty {
3557
3565
ty:: Adt ( adt, ..) => {
@@ -5195,13 +5203,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5195
5203
if let Some ( adt_def) = adt_def {
5196
5204
match adt_def. adt_kind ( ) {
5197
5205
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?" ) ;
5199
5207
} ,
5200
5208
AdtKind :: Struct |
5201
5209
AdtKind :: Union => {
5202
- err. span_label (
5210
+ err. span_suggestion_with_applicability (
5203
5211
span,
5204
- format ! ( "did you mean `Self {{ /* fields */ }}`?" ) ,
5212
+ "use curly brackets" ,
5213
+ String :: from ( "Self { /* fields */ }" ) ,
5214
+ Applicability :: HasPlaceholders ,
5205
5215
) ;
5206
5216
}
5207
5217
}
0 commit comments