1
- use rustc_errors:: { fluent, AddToDiagnostic , Applicability , DecorateLint , EmissionGuarantee } ;
1
+ use rustc_errors:: { fluent, AddToDiagnostic , Applicability , DecorateLint } ;
2
2
use rustc_hir:: def_id:: DefId ;
3
3
use rustc_macros:: { LintDiagnostic , Subdiagnostic } ;
4
4
use rustc_middle:: ty:: { Predicate , Ty , TyCtxt } ;
@@ -88,9 +88,11 @@ pub struct NonFmtPanicUnused {
88
88
pub suggestion : Option < Span > ,
89
89
}
90
90
91
- impl < G : EmissionGuarantee > DecorateLint < ' _ , G > for NonFmtPanicUnused {
92
- fn decorate_lint ( self , diag : rustc_errors:: LintDiagnosticBuilder < ' _ , G > ) {
93
- let mut diag = diag. build ( fluent:: lint_non_fmt_panic_unused) ;
91
+ impl < ' a > DecorateLint < ' a , ( ) > for NonFmtPanicUnused {
92
+ fn decorate_lint < ' b > (
93
+ self ,
94
+ diag : & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > ,
95
+ ) -> & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > {
94
96
diag. set_arg ( "count" , self . count ) ;
95
97
diag. note ( fluent:: note) ;
96
98
if let Some ( span) = self . suggestion {
@@ -107,7 +109,11 @@ impl<G: EmissionGuarantee> DecorateLint<'_, G> for NonFmtPanicUnused {
107
109
Applicability :: MachineApplicable ,
108
110
) ;
109
111
}
110
- diag. emit ( ) ;
112
+ diag
113
+ }
114
+
115
+ fn msg ( & self ) -> rustc_errors:: DiagnosticMessage {
116
+ fluent:: lint_non_fmt_panic_unused
111
117
}
112
118
}
113
119
@@ -202,7 +208,7 @@ impl AddToDiagnostic for NonSnakeCaseDiagSub {
202
208
Applicability :: MaybeIncorrect ,
203
209
) ;
204
210
}
205
- } ;
211
+ }
206
212
}
207
213
}
208
214
@@ -262,12 +268,17 @@ pub struct DropTraitConstraintsDiag<'a> {
262
268
pub def_id : DefId ,
263
269
}
264
270
265
- impl < ' a , G : EmissionGuarantee > DecorateLint < ' _ , G > for DropTraitConstraintsDiag < ' a > {
266
- fn decorate_lint ( self , diag : rustc_errors:: LintDiagnosticBuilder < ' _ , G > ) {
267
- let mut diag = diag. build ( fluent:: lint_drop_trait_constraints) ;
271
+ impl < ' a > DecorateLint < ' a , ( ) > for DropTraitConstraintsDiag < ' _ > {
272
+ fn decorate_lint < ' b > (
273
+ self ,
274
+ diag : & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > ,
275
+ ) -> & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > {
268
276
diag. set_arg ( "predicate" , self . predicate ) ;
269
- diag. set_arg ( "needs_drop" , self . tcx . def_path_str ( self . def_id ) ) ;
270
- diag. emit ( ) ;
277
+ diag. set_arg ( "needs_drop" , self . tcx . def_path_str ( self . def_id ) )
278
+ }
279
+
280
+ fn msg ( & self ) -> rustc_errors:: DiagnosticMessage {
281
+ fluent:: lint_drop_trait_constraints
271
282
}
272
283
}
273
284
@@ -276,11 +287,16 @@ pub struct DropGlue<'a> {
276
287
pub def_id : DefId ,
277
288
}
278
289
279
- impl < ' a , G : EmissionGuarantee > DecorateLint < ' _ , G > for DropGlue < ' a > {
280
- fn decorate_lint ( self , diag : rustc_errors:: LintDiagnosticBuilder < ' _ , G > ) {
281
- let mut diag = diag. build ( fluent:: lint_drop_glue) ;
282
- diag. set_arg ( "needs_drop" , self . tcx . def_path_str ( self . def_id ) ) ;
283
- diag. emit ( ) ;
290
+ impl < ' a > DecorateLint < ' a , ( ) > for DropGlue < ' _ > {
291
+ fn decorate_lint < ' b > (
292
+ self ,
293
+ diag : & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > ,
294
+ ) -> & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > {
295
+ diag. set_arg ( "needs_drop" , self . tcx . def_path_str ( self . def_id ) )
296
+ }
297
+
298
+ fn msg ( & self ) -> rustc_errors:: DiagnosticMessage {
299
+ fluent:: lint_drop_glue
284
300
}
285
301
}
286
302
@@ -359,9 +375,11 @@ pub struct OverflowingInt<'a> {
359
375
}
360
376
361
377
// FIXME: refactor with `Option<&'a str>` in macro
362
- impl < ' a , G : EmissionGuarantee > DecorateLint < ' _ , G > for OverflowingInt < ' a > {
363
- fn decorate_lint ( self , diag : rustc_errors:: LintDiagnosticBuilder < ' _ , G > ) {
364
- let mut diag = diag. build ( fluent:: lint_overflowing_int) ;
378
+ impl < ' a > DecorateLint < ' a , ( ) > for OverflowingInt < ' _ > {
379
+ fn decorate_lint < ' b > (
380
+ self ,
381
+ diag : & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > ,
382
+ ) -> & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > {
365
383
diag. set_arg ( "ty" , self . ty ) ;
366
384
diag. set_arg ( "lit" , self . lit ) ;
367
385
diag. set_arg ( "min" , self . min ) ;
@@ -371,7 +389,11 @@ impl<'a, G: EmissionGuarantee> DecorateLint<'_, G> for OverflowingInt<'a> {
371
389
diag. set_arg ( "suggestion_ty" , suggestion_ty) ;
372
390
diag. help ( fluent:: help) ;
373
391
}
374
- diag. emit ( ) ;
392
+ diag
393
+ }
394
+
395
+ fn msg ( & self ) -> rustc_errors:: DiagnosticMessage {
396
+ fluent:: lint_overflowing_int
375
397
}
376
398
}
377
399
@@ -484,17 +506,23 @@ pub struct UnusedDef<'a, 'b> {
484
506
}
485
507
486
508
// FIXME: refactor with `Option<String>` in macro
487
- impl < ' a , ' b , G : EmissionGuarantee > DecorateLint < ' _ , G > for UnusedDef < ' a , ' b > {
488
- fn decorate_lint ( self , diag : rustc_errors:: LintDiagnosticBuilder < ' _ , G > ) {
489
- let mut diag = diag. build ( fluent:: lint_unused_def) ;
509
+ impl < ' a > DecorateLint < ' a , ( ) > for UnusedDef < ' _ , ' _ > {
510
+ fn decorate_lint < ' b > (
511
+ self ,
512
+ diag : & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > ,
513
+ ) -> & ' b mut rustc_errors:: DiagnosticBuilder < ' a , ( ) > {
490
514
diag. set_arg ( "pre" , self . pre ) ;
491
515
diag. set_arg ( "post" , self . post ) ;
492
516
diag. set_arg ( "def" , self . cx . tcx . def_path_str ( self . def_id ) ) ;
493
517
// check for #[must_use = "..."]
494
518
if let Some ( note) = self . note {
495
519
diag. note ( note. as_str ( ) ) ;
496
520
}
497
- diag. emit ( ) ;
521
+ diag
522
+ }
523
+
524
+ fn msg ( & self ) -> rustc_errors:: DiagnosticMessage {
525
+ fluent:: lint_unused_def
498
526
}
499
527
}
500
528
0 commit comments