@@ -45,7 +45,7 @@ pub use coercion::can_coerce;
45
45
use fn_ctxt:: FnCtxt ;
46
46
use rustc_data_structures:: unord:: UnordSet ;
47
47
use rustc_errors:: codes:: * ;
48
- use rustc_errors:: { pluralize , struct_span_code_err, Applicability , ErrorGuaranteed } ;
48
+ use rustc_errors:: { struct_span_code_err, Applicability , ErrorGuaranteed } ;
49
49
use rustc_hir as hir;
50
50
use rustc_hir:: def:: { DefKind , Res } ;
51
51
use rustc_hir:: intravisit:: Visitor ;
@@ -422,40 +422,15 @@ fn report_unexpected_variant_res(
422
422
err
423
423
}
424
424
Res :: Def ( DefKind :: Variant , _) if expr. is_none ( ) => {
425
- let fields = tcx
426
- . expect_variant_res ( res)
427
- . fields
428
- . raw
429
- . iter ( )
430
- . map ( |field| field. name . to_ident_string ( ) )
431
- . collect :: < Vec < _ > > ( ) ;
432
-
433
425
err. span_label ( span, format ! ( "not a {expected}" ) ) ;
434
426
435
- let span = qpath. span ( ) . shrink_to_hi ( ) . to ( span. shrink_to_hi ( ) ) ;
436
427
err. span_suggestion_verbose (
437
- span,
438
- "use the struct variant pattern syntax" ,
439
- if fields. is_empty ( ) {
440
- " {}" . to_string ( )
441
- } else {
442
- format ! ( " {{ {} }}" , fields. join( ", " ) )
443
- } ,
444
- Applicability :: MachineApplicable ,
428
+ qpath. span ( ) . shrink_to_hi ( ) . to ( span. shrink_to_hi ( ) ) ,
429
+ "the struct variant's fields are being ignored" ,
430
+ " { /* field: _, field: _ */ }" ,
431
+ Applicability :: HasPlaceholders ,
445
432
) ;
446
433
447
- if !fields. is_empty ( ) {
448
- let len = fields. len ( ) ;
449
-
450
- let msg = format ! (
451
- "if you don't care about {these} field{s}, you can explicitly ignore {them}" ,
452
- these = pluralize!( "this" , len) ,
453
- s = pluralize!( len) ,
454
- them = if len == 1 { "it" } else { "them" } ,
455
- ) ;
456
- err. span_suggestion_verbose ( span, msg, " { .. }" , Applicability :: MachineApplicable ) ;
457
- }
458
-
459
434
err
460
435
}
461
436
_ => err. with_span_label ( span, format ! ( "not a {expected}" ) ) ,
0 commit comments