@@ -12,8 +12,6 @@ use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
12
12
use rustc_middle:: ty:: { MainDefinition , Ty } ;
13
13
use rustc_span:: { Span , Symbol , DUMMY_SP } ;
14
14
15
- use rustc_errors:: { pluralize, AddToDiagnostic , Diagnostic , SubdiagnosticMessage } ;
16
-
17
15
use crate :: lang_items:: Duplicate ;
18
16
19
17
#[ derive( LintDiagnostic ) ]
@@ -1502,28 +1500,10 @@ pub struct IgnoredDerivedImpls {
1502
1500
pub trait_list_len : usize ,
1503
1501
}
1504
1502
1503
+ #[ derive( Subdiagnostic ) ]
1504
+ #[ multipart_suggestion( passes_change_fields_to_be_of_unit_type, applicability = "has-placeholders" ) ]
1505
1505
pub struct ChangeFieldsToBeOfUnitType {
1506
1506
pub num : usize ,
1507
+ #[ suggestion_part( code = "()" ) ]
1507
1508
pub spans : Vec < Span > ,
1508
1509
}
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