@@ -12,8 +12,6 @@ use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
1212use rustc_middle:: ty:: { MainDefinition , Ty } ;
1313use rustc_span:: { Span , Symbol , DUMMY_SP } ;
1414
15- use rustc_errors:: { pluralize, AddToDiagnostic , Diagnostic , SubdiagnosticMessage } ;
16-
1715use crate :: lang_items:: Duplicate ;
1816
1917#[ derive( LintDiagnostic ) ]
@@ -1502,28 +1500,10 @@ pub struct IgnoredDerivedImpls {
15021500 pub trait_list_len : usize ,
15031501}
15041502
1503+ #[ derive( Subdiagnostic ) ]
1504+ #[ multipart_suggestion( passes_change_fields_to_be_of_unit_type, applicability = "has-placeholders" ) ]
15051505pub struct ChangeFieldsToBeOfUnitType {
15061506 pub num : usize ,
1507+ #[ suggestion_part( code = "()" ) ]
15071508 pub spans : Vec < Span > ,
15081509}
1509-
1510- // FIXME: Replace this impl with a derive.
1511- impl AddToDiagnostic for ChangeFieldsToBeOfUnitType {
1512- fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
1513- where
1514- F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
1515- {
1516- diag. multipart_suggestion (
1517- & format ! (
1518- "consider changing the field{s} to be of unit type to \
1519- suppress this warning while preserving the field \
1520- numbering, or remove the field{s}",
1521- s = pluralize!( self . num)
1522- ) ,
1523- self . spans . iter ( ) . map ( |sp| ( * sp, "()" . to_string ( ) ) ) . collect ( ) ,
1524- // "HasPlaceholders" because applying this fix by itself isn't
1525- // enough: All constructor calls have to be adjusted as well
1526- Applicability :: HasPlaceholders ,
1527- ) ;
1528- }
1529- }
0 commit comments