@@ -5,8 +5,8 @@ use std::num::NonZeroU32;
5
5
use crate :: errors:: RequestedLevel ;
6
6
use crate :: fluent_generated as fluent;
7
7
use rustc_errors:: {
8
- AddToDiagnostic , Applicability , DecorateLint , DiagnosticMessage , DiagnosticStyledString ,
9
- SuggestionStyle ,
8
+ AddToDiagnostic , Applicability , DecorateLint , Diagnostic , DiagnosticBuilder , DiagnosticMessage ,
9
+ DiagnosticStyledString , SubdiagnosticMessage , SuggestionStyle ,
10
10
} ;
11
11
use rustc_hir:: def_id:: DefId ;
12
12
use rustc_macros:: { LintDiagnostic , Subdiagnostic } ;
@@ -239,7 +239,7 @@ pub struct BuiltinUngatedAsyncFnTrackCaller<'a> {
239
239
}
240
240
241
241
impl < ' a > DecorateLint < ' a , ( ) > for BuiltinUngatedAsyncFnTrackCaller < ' _ > {
242
- fn decorate_lint < ' b > ( self , diag : & ' b mut rustc_errors :: DiagnosticBuilder < ' a , ( ) > ) {
242
+ fn decorate_lint < ' b > ( self , diag : & ' b mut DiagnosticBuilder < ' a , ( ) > ) {
243
243
diag. span_label ( self . label , fluent:: lint_label) ;
244
244
rustc_session:: parse:: add_feature_diagnostics (
245
245
diag,
@@ -268,20 +268,17 @@ pub struct SuggestChangingAssocTypes<'a, 'b> {
268
268
}
269
269
270
270
impl AddToDiagnostic for SuggestChangingAssocTypes < ' _ , ' _ > {
271
- fn add_to_diagnostic_with < F > ( self , diag : & mut rustc_errors :: Diagnostic , _: F )
271
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
272
272
where
273
- F : Fn (
274
- & mut rustc_errors:: Diagnostic ,
275
- rustc_errors:: SubdiagnosticMessage ,
276
- ) -> rustc_errors:: SubdiagnosticMessage ,
273
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
277
274
{
278
275
// Access to associates types should use `<T as Bound>::Assoc`, which does not need a
279
276
// bound. Let's see if this type does that.
280
277
281
278
// We use a HIR visitor to walk the type.
282
279
use rustc_hir:: intravisit:: { self , Visitor } ;
283
280
struct WalkAssocTypes < ' a > {
284
- err : & ' a mut rustc_errors :: Diagnostic ,
281
+ err : & ' a mut Diagnostic ,
285
282
}
286
283
impl Visitor < ' _ > for WalkAssocTypes < ' _ > {
287
284
fn visit_qpath (
@@ -326,12 +323,9 @@ pub struct BuiltinTypeAliasGenericBoundsSuggestion {
326
323
}
327
324
328
325
impl AddToDiagnostic for BuiltinTypeAliasGenericBoundsSuggestion {
329
- fn add_to_diagnostic_with < F > ( self , diag : & mut rustc_errors :: Diagnostic , _: F )
326
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
330
327
where
331
- F : Fn (
332
- & mut rustc_errors:: Diagnostic ,
333
- rustc_errors:: SubdiagnosticMessage ,
334
- ) -> rustc_errors:: SubdiagnosticMessage ,
328
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
335
329
{
336
330
diag. multipart_suggestion (
337
331
fluent:: lint_suggestion,
@@ -425,7 +419,7 @@ pub struct BuiltinUnpermittedTypeInit<'a> {
425
419
}
426
420
427
421
impl < ' a > DecorateLint < ' a , ( ) > for BuiltinUnpermittedTypeInit < ' _ > {
428
- fn decorate_lint < ' b > ( self , diag : & ' b mut rustc_errors :: DiagnosticBuilder < ' a , ( ) > ) {
422
+ fn decorate_lint < ' b > ( self , diag : & ' b mut DiagnosticBuilder < ' a , ( ) > ) {
429
423
diag. arg ( "ty" , self . ty ) ;
430
424
diag. span_label ( self . label , fluent:: lint_builtin_unpermitted_type_init_label) ;
431
425
if let InhabitedPredicate :: True = self . ty . inhabited_predicate ( self . tcx ) {
@@ -438,7 +432,7 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUnpermittedTypeInit<'_> {
438
432
self . sub . add_to_diagnostic ( diag) ;
439
433
}
440
434
441
- fn msg ( & self ) -> rustc_errors :: DiagnosticMessage {
435
+ fn msg ( & self ) -> DiagnosticMessage {
442
436
self . msg . clone ( )
443
437
}
444
438
}
@@ -449,12 +443,9 @@ pub struct BuiltinUnpermittedTypeInitSub {
449
443
}
450
444
451
445
impl AddToDiagnostic for BuiltinUnpermittedTypeInitSub {
452
- fn add_to_diagnostic_with < F > ( self , diag : & mut rustc_errors :: Diagnostic , _: F )
446
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
453
447
where
454
- F : Fn (
455
- & mut rustc_errors:: Diagnostic ,
456
- rustc_errors:: SubdiagnosticMessage ,
457
- ) -> rustc_errors:: SubdiagnosticMessage ,
448
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
458
449
{
459
450
let mut err = self . err ;
460
451
loop {
@@ -506,12 +497,9 @@ pub struct BuiltinClashingExternSub<'a> {
506
497
}
507
498
508
499
impl AddToDiagnostic for BuiltinClashingExternSub < ' _ > {
509
- fn add_to_diagnostic_with < F > ( self , diag : & mut rustc_errors :: Diagnostic , _: F )
500
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
510
501
where
511
- F : Fn (
512
- & mut rustc_errors:: Diagnostic ,
513
- rustc_errors:: SubdiagnosticMessage ,
514
- ) -> rustc_errors:: SubdiagnosticMessage ,
502
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
515
503
{
516
504
let mut expected_str = DiagnosticStyledString :: new ( ) ;
517
505
expected_str. push ( self . expected . fn_sig ( self . tcx ) . to_string ( ) , false ) ;
@@ -779,12 +767,9 @@ pub struct HiddenUnicodeCodepointsDiagLabels {
779
767
}
780
768
781
769
impl AddToDiagnostic for HiddenUnicodeCodepointsDiagLabels {
782
- fn add_to_diagnostic_with < F > ( self , diag : & mut rustc_errors :: Diagnostic , _: F )
770
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
783
771
where
784
- F : Fn (
785
- & mut rustc_errors:: Diagnostic ,
786
- rustc_errors:: SubdiagnosticMessage ,
787
- ) -> rustc_errors:: SubdiagnosticMessage ,
772
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
788
773
{
789
774
for ( c, span) in self . spans {
790
775
diag. span_label ( span, format ! ( "{c:?}" ) ) ;
@@ -799,12 +784,9 @@ pub enum HiddenUnicodeCodepointsDiagSub {
799
784
800
785
// Used because of multiple multipart_suggestion and note
801
786
impl AddToDiagnostic for HiddenUnicodeCodepointsDiagSub {
802
- fn add_to_diagnostic_with < F > ( self , diag : & mut rustc_errors :: Diagnostic , _: F )
787
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
803
788
where
804
- F : Fn (
805
- & mut rustc_errors:: Diagnostic ,
806
- rustc_errors:: SubdiagnosticMessage ,
807
- ) -> rustc_errors:: SubdiagnosticMessage ,
789
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
808
790
{
809
791
match self {
810
792
HiddenUnicodeCodepointsDiagSub :: Escape { spans } => {
@@ -953,12 +935,9 @@ pub struct NonBindingLetSub {
953
935
}
954
936
955
937
impl AddToDiagnostic for NonBindingLetSub {
956
- fn add_to_diagnostic_with < F > ( self , diag : & mut rustc_errors :: Diagnostic , _: F )
938
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
957
939
where
958
- F : Fn (
959
- & mut rustc_errors:: Diagnostic ,
960
- rustc_errors:: SubdiagnosticMessage ,
961
- ) -> rustc_errors:: SubdiagnosticMessage ,
940
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
962
941
{
963
942
diag. span_suggestion_verbose (
964
943
self . suggestion ,
@@ -1147,7 +1126,7 @@ pub struct NonFmtPanicUnused {
1147
1126
1148
1127
// Used because of two suggestions based on one Option<Span>
1149
1128
impl < ' a > DecorateLint < ' a , ( ) > for NonFmtPanicUnused {
1150
- fn decorate_lint < ' b > ( self , diag : & ' b mut rustc_errors :: DiagnosticBuilder < ' a , ( ) > ) {
1129
+ fn decorate_lint < ' b > ( self , diag : & ' b mut DiagnosticBuilder < ' a , ( ) > ) {
1151
1130
diag. arg ( "count" , self . count ) ;
1152
1131
diag. note ( fluent:: lint_note) ;
1153
1132
if let Some ( span) = self . suggestion {
@@ -1166,7 +1145,7 @@ impl<'a> DecorateLint<'a, ()> for NonFmtPanicUnused {
1166
1145
}
1167
1146
}
1168
1147
1169
- fn msg ( & self ) -> rustc_errors :: DiagnosticMessage {
1148
+ fn msg ( & self ) -> DiagnosticMessage {
1170
1149
fluent:: lint_non_fmt_panic_unused
1171
1150
}
1172
1151
}
@@ -1224,12 +1203,9 @@ pub enum NonSnakeCaseDiagSub {
1224
1203
}
1225
1204
1226
1205
impl AddToDiagnostic for NonSnakeCaseDiagSub {
1227
- fn add_to_diagnostic_with < F > ( self , diag : & mut rustc_errors :: Diagnostic , _: F )
1206
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
1228
1207
where
1229
- F : Fn (
1230
- & mut rustc_errors:: Diagnostic ,
1231
- rustc_errors:: SubdiagnosticMessage ,
1232
- ) -> rustc_errors:: SubdiagnosticMessage ,
1208
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
1233
1209
{
1234
1210
match self {
1235
1211
NonSnakeCaseDiagSub :: Label { span } => {
@@ -1342,12 +1318,12 @@ pub struct DropTraitConstraintsDiag<'a> {
1342
1318
1343
1319
// Needed for def_path_str
1344
1320
impl < ' a > DecorateLint < ' a , ( ) > for DropTraitConstraintsDiag < ' _ > {
1345
- fn decorate_lint < ' b > ( self , diag : & ' b mut rustc_errors :: DiagnosticBuilder < ' a , ( ) > ) {
1321
+ fn decorate_lint < ' b > ( self , diag : & ' b mut DiagnosticBuilder < ' a , ( ) > ) {
1346
1322
diag. arg ( "predicate" , self . predicate ) ;
1347
1323
diag. arg ( "needs_drop" , self . tcx . def_path_str ( self . def_id ) ) ;
1348
1324
}
1349
1325
1350
- fn msg ( & self ) -> rustc_errors :: DiagnosticMessage {
1326
+ fn msg ( & self ) -> DiagnosticMessage {
1351
1327
fluent:: lint_drop_trait_constraints
1352
1328
}
1353
1329
}
@@ -1359,11 +1335,11 @@ pub struct DropGlue<'a> {
1359
1335
1360
1336
// Needed for def_path_str
1361
1337
impl < ' a > DecorateLint < ' a , ( ) > for DropGlue < ' _ > {
1362
- fn decorate_lint < ' b > ( self , diag : & ' b mut rustc_errors :: DiagnosticBuilder < ' a , ( ) > ) {
1338
+ fn decorate_lint < ' b > ( self , diag : & ' b mut DiagnosticBuilder < ' a , ( ) > ) {
1363
1339
diag. arg ( "needs_drop" , self . tcx . def_path_str ( self . def_id ) ) ;
1364
1340
}
1365
1341
1366
- fn msg ( & self ) -> rustc_errors :: DiagnosticMessage {
1342
+ fn msg ( & self ) -> DiagnosticMessage {
1367
1343
fluent:: lint_drop_glue
1368
1344
}
1369
1345
}
@@ -1423,12 +1399,9 @@ pub enum OverflowingBinHexSign {
1423
1399
}
1424
1400
1425
1401
impl AddToDiagnostic for OverflowingBinHexSign {
1426
- fn add_to_diagnostic_with < F > ( self , diag : & mut rustc_errors :: Diagnostic , _: F )
1402
+ fn add_to_diagnostic_with < F > ( self , diag : & mut Diagnostic , _: F )
1427
1403
where
1428
- F : Fn (
1429
- & mut rustc_errors:: Diagnostic ,
1430
- rustc_errors:: SubdiagnosticMessage ,
1431
- ) -> rustc_errors:: SubdiagnosticMessage ,
1404
+ F : Fn ( & mut Diagnostic , SubdiagnosticMessage ) -> SubdiagnosticMessage ,
1432
1405
{
1433
1406
match self {
1434
1407
OverflowingBinHexSign :: Positive => {
@@ -1633,7 +1606,7 @@ pub struct ImproperCTypes<'a> {
1633
1606
1634
1607
// Used because of the complexity of Option<DiagnosticMessage>, DiagnosticMessage, and Option<Span>
1635
1608
impl < ' a > DecorateLint < ' a , ( ) > for ImproperCTypes < ' _ > {
1636
- fn decorate_lint < ' b > ( self , diag : & ' b mut rustc_errors :: DiagnosticBuilder < ' a , ( ) > ) {
1609
+ fn decorate_lint < ' b > ( self , diag : & ' b mut DiagnosticBuilder < ' a , ( ) > ) {
1637
1610
diag. arg ( "ty" , self . ty ) ;
1638
1611
diag. arg ( "desc" , self . desc ) ;
1639
1612
diag. span_label ( self . label , fluent:: lint_label) ;
@@ -1646,7 +1619,7 @@ impl<'a> DecorateLint<'a, ()> for ImproperCTypes<'_> {
1646
1619
}
1647
1620
}
1648
1621
1649
- fn msg ( & self ) -> rustc_errors :: DiagnosticMessage {
1622
+ fn msg ( & self ) -> DiagnosticMessage {
1650
1623
fluent:: lint_improper_ctypes
1651
1624
}
1652
1625
}
@@ -1776,7 +1749,7 @@ pub enum UnusedDefSuggestion {
1776
1749
1777
1750
// Needed because of def_path_str
1778
1751
impl < ' a > DecorateLint < ' a , ( ) > for UnusedDef < ' _ , ' _ > {
1779
- fn decorate_lint < ' b > ( self , diag : & ' b mut rustc_errors :: DiagnosticBuilder < ' a , ( ) > ) {
1752
+ fn decorate_lint < ' b > ( self , diag : & ' b mut DiagnosticBuilder < ' a , ( ) > ) {
1780
1753
diag. arg ( "pre" , self . pre ) ;
1781
1754
diag. arg ( "post" , self . post ) ;
1782
1755
diag. arg ( "def" , self . cx . tcx . def_path_str ( self . def_id ) ) ;
@@ -1789,7 +1762,7 @@ impl<'a> DecorateLint<'a, ()> for UnusedDef<'_, '_> {
1789
1762
}
1790
1763
}
1791
1764
1792
- fn msg ( & self ) -> rustc_errors :: DiagnosticMessage {
1765
+ fn msg ( & self ) -> DiagnosticMessage {
1793
1766
fluent:: lint_unused_def
1794
1767
}
1795
1768
}
@@ -1859,14 +1832,14 @@ pub struct AsyncFnInTraitDiag {
1859
1832
}
1860
1833
1861
1834
impl < ' a > DecorateLint < ' a , ( ) > for AsyncFnInTraitDiag {
1862
- fn decorate_lint < ' b > ( self , diag : & ' b mut rustc_errors :: DiagnosticBuilder < ' a , ( ) > ) {
1835
+ fn decorate_lint < ' b > ( self , diag : & ' b mut DiagnosticBuilder < ' a , ( ) > ) {
1863
1836
diag. note ( fluent:: lint_note) ;
1864
1837
if let Some ( sugg) = self . sugg {
1865
1838
diag. multipart_suggestion ( fluent:: lint_suggestion, sugg, Applicability :: MaybeIncorrect ) ;
1866
1839
}
1867
1840
}
1868
1841
1869
- fn msg ( & self ) -> rustc_errors :: DiagnosticMessage {
1842
+ fn msg ( & self ) -> DiagnosticMessage {
1870
1843
fluent:: lint_async_fn_in_trait
1871
1844
}
1872
1845
}
0 commit comments