4
4
use std:: borrow:: Cow ;
5
5
6
6
use rustc_ast:: util:: unicode:: TEXT_FLOW_CONTROL_CHARS ;
7
- use rustc_errors:: Applicability ;
8
- use rustc_errors:: { elided_lifetime_in_path_suggestion , DiagArgValue , MultiSpan } ;
7
+ use rustc_errors:: elided_lifetime_in_path_suggestion ;
8
+ use rustc_errors:: { Applicability , Diag , DiagArgValue , LintDiagnostic } ;
9
9
use rustc_middle:: middle:: stability;
10
- use rustc_session:: lint:: { BuiltinLintDiag , Lint } ;
10
+ use rustc_session:: lint:: BuiltinLintDiag ;
11
+ use rustc_session:: Session ;
11
12
use rustc_span:: BytePos ;
12
13
13
- use crate :: { lints, EarlyContext , LintContext as _ } ;
14
+ use crate :: lints;
14
15
15
16
mod check_cfg;
16
17
17
- pub ( super ) fn emit_buffered_lint (
18
- ctx : & EarlyContext < ' _ > ,
19
- lint : & ' static Lint ,
20
- span : MultiSpan ,
21
- diagnostic : BuiltinLintDiag ,
22
- ) {
23
- let sess = ctx. sess ( ) ;
18
+ pub ( super ) fn decorate_lint ( sess : & Session , diagnostic : BuiltinLintDiag , diag : & mut Diag < ' _ , ( ) > ) {
24
19
match diagnostic {
25
20
BuiltinLintDiag :: UnicodeTextFlow ( comment_span, content) => {
26
21
let spans: Vec < _ > = content
@@ -39,16 +34,14 @@ pub(super) fn emit_buffered_lint(
39
34
let suggestions = ( !spans. is_empty ( ) ) . then_some ( lints:: UnicodeTextFlowSuggestion {
40
35
spans : spans. iter ( ) . map ( |( _c, span) | * span) . collect ( ) ,
41
36
} ) ;
42
- ctx. emit_span_lint (
43
- lint,
44
- span,
45
- lints:: UnicodeTextFlow {
46
- comment_span,
47
- characters,
48
- suggestions,
49
- num_codepoints : spans. len ( ) ,
50
- } ,
51
- )
37
+
38
+ lints:: UnicodeTextFlow {
39
+ comment_span,
40
+ characters,
41
+ suggestions,
42
+ num_codepoints : spans. len ( ) ,
43
+ }
44
+ . decorate_lint ( diag) ;
52
45
}
53
46
BuiltinLintDiag :: AbsPathWithModule ( mod_span) => {
54
47
let ( replacement, applicability) = match sess. source_map ( ) . span_to_snippet ( mod_span) {
@@ -61,48 +54,35 @@ pub(super) fn emit_buffered_lint(
61
54
}
62
55
Err ( _) => ( "crate::<path>" . to_string ( ) , Applicability :: HasPlaceholders ) ,
63
56
} ;
64
- ctx. emit_span_lint (
65
- lint,
66
- span,
67
- lints:: AbsPathWithModule {
68
- sugg : lints:: AbsPathWithModuleSugg {
69
- span : mod_span,
70
- applicability,
71
- replacement,
72
- } ,
73
- } ,
74
- ) ;
75
- }
76
- BuiltinLintDiag :: ProcMacroDeriveResolutionFallback { span : macro_span, ns, ident } => ctx
77
- . emit_span_lint (
78
- lint,
79
- span,
80
- lints:: ProcMacroDeriveResolutionFallback { span : macro_span, ns, ident } ,
81
- ) ,
82
- BuiltinLintDiag :: MacroExpandedMacroExportsAccessedByAbsolutePaths ( span_def) => ctx
83
- . emit_span_lint (
84
- lint,
85
- span,
86
- lints:: MacroExpandedMacroExportsAccessedByAbsolutePaths { definition : span_def } ,
87
- ) ,
57
+ lints:: AbsPathWithModule {
58
+ sugg : lints:: AbsPathWithModuleSugg { span : mod_span, applicability, replacement } ,
59
+ }
60
+ . decorate_lint ( diag) ;
61
+ }
62
+ BuiltinLintDiag :: ProcMacroDeriveResolutionFallback { span : macro_span, ns, ident } => {
63
+ lints:: ProcMacroDeriveResolutionFallback { span : macro_span, ns, ident }
64
+ . decorate_lint ( diag)
65
+ }
66
+ BuiltinLintDiag :: MacroExpandedMacroExportsAccessedByAbsolutePaths ( span_def) => {
67
+ lints:: MacroExpandedMacroExportsAccessedByAbsolutePaths { definition : span_def }
68
+ . decorate_lint ( diag)
69
+ }
70
+
88
71
BuiltinLintDiag :: ElidedLifetimesInPaths ( n, path_span, incl_angl_brckt, insertion_span) => {
89
- ctx. emit_span_lint (
90
- lint,
91
- span,
92
- lints:: ElidedLifetimesInPaths {
93
- subdiag : elided_lifetime_in_path_suggestion (
94
- sess. source_map ( ) ,
95
- n,
96
- path_span,
97
- incl_angl_brckt,
98
- insertion_span,
99
- ) ,
100
- } ,
101
- ) ;
72
+ lints:: ElidedLifetimesInPaths {
73
+ subdiag : elided_lifetime_in_path_suggestion (
74
+ sess. source_map ( ) ,
75
+ n,
76
+ path_span,
77
+ incl_angl_brckt,
78
+ insertion_span,
79
+ ) ,
80
+ }
81
+ . decorate_lint ( diag) ;
102
82
}
103
83
BuiltinLintDiag :: UnknownCrateTypes { span, candidate } => {
104
84
let sugg = candidate. map ( |candidate| lints:: UnknownCrateTypesSub { span, candidate } ) ;
105
- ctx . emit_span_lint ( lint , span , lints:: UnknownCrateTypes { sugg } ) ;
85
+ lints:: UnknownCrateTypes { sugg } . decorate_lint ( diag ) ;
106
86
}
107
87
BuiltinLintDiag :: UnusedImports {
108
88
remove_whole_use,
@@ -119,18 +99,15 @@ pub(super) fn emit_buffered_lint(
119
99
let test_module_span =
120
100
test_module_span. map ( |span| sess. source_map ( ) . guess_head_span ( span) ) ;
121
101
122
- ctx. emit_span_lint (
123
- lint,
124
- span,
125
- lints:: UnusedImports {
126
- sugg,
127
- test_module_span,
128
- num_snippets : span_snippets. len ( ) ,
129
- span_snippets : DiagArgValue :: StrListSepByAnd (
130
- span_snippets. into_iter ( ) . map ( Cow :: Owned ) . collect ( ) ,
131
- ) ,
132
- } ,
133
- ) ;
102
+ lints:: UnusedImports {
103
+ sugg,
104
+ test_module_span,
105
+ num_snippets : span_snippets. len ( ) ,
106
+ span_snippets : DiagArgValue :: StrListSepByAnd (
107
+ span_snippets. into_iter ( ) . map ( Cow :: Owned ) . collect ( ) ,
108
+ ) ,
109
+ }
110
+ . decorate_lint ( diag) ;
134
111
}
135
112
BuiltinLintDiag :: RedundantImport ( spans, ident) => {
136
113
let subs = spans
@@ -144,7 +121,7 @@ pub(super) fn emit_buffered_lint(
144
121
} ) ( span)
145
122
} )
146
123
. collect ( ) ;
147
- ctx . emit_span_lint ( lint , span , lints:: RedundantImport { subs, ident } ) ;
124
+ lints:: RedundantImport { subs, ident } . decorate_lint ( diag ) ;
148
125
}
149
126
BuiltinLintDiag :: DeprecatedMacro {
150
127
suggestion,
@@ -158,90 +135,63 @@ pub(super) fn emit_buffered_lint(
158
135
kind : "macro" . to_owned ( ) ,
159
136
suggestion,
160
137
} ) ;
161
- ctx. emit_span_lint (
162
- lint,
163
- span,
164
- stability:: Deprecated { sub, kind : "macro" . to_owned ( ) , path, note, since_kind } ,
165
- ) ;
138
+
139
+ stability:: Deprecated { sub, kind : "macro" . to_owned ( ) , path, note, since_kind }
140
+ . decorate_lint ( diag) ;
166
141
}
167
142
BuiltinLintDiag :: UnusedDocComment ( attr_span) => {
168
- ctx . emit_span_lint ( lint , span , lints:: UnusedDocComment { span : attr_span } ) ;
143
+ lints:: UnusedDocComment { span : attr_span } . decorate_lint ( diag ) ;
169
144
}
170
145
BuiltinLintDiag :: PatternsInFnsWithoutBody { span : remove_span, ident, is_foreign } => {
171
146
let sub = lints:: PatternsInFnsWithoutBodySub { ident, span : remove_span } ;
172
-
173
- ctx. emit_span_lint (
174
- lint,
175
- span,
176
- if is_foreign {
177
- lints:: PatternsInFnsWithoutBody :: Foreign { sub }
178
- } else {
179
- lints:: PatternsInFnsWithoutBody :: Bodiless { sub }
180
- } ,
181
- ) ;
147
+ if is_foreign {
148
+ lints:: PatternsInFnsWithoutBody :: Foreign { sub }
149
+ } else {
150
+ lints:: PatternsInFnsWithoutBody :: Bodiless { sub }
151
+ }
152
+ . decorate_lint ( diag) ;
182
153
}
183
154
BuiltinLintDiag :: MissingAbi ( label_span, default_abi) => {
184
- ctx. emit_span_lint (
185
- lint,
186
- span,
187
- lints:: MissingAbi { span : label_span, default_abi : default_abi. name ( ) } ,
188
- ) ;
155
+ lints:: MissingAbi { span : label_span, default_abi : default_abi. name ( ) }
156
+ . decorate_lint ( diag) ;
189
157
}
190
158
BuiltinLintDiag :: LegacyDeriveHelpers ( label_span) => {
191
- ctx . emit_span_lint ( lint , span , lints:: LegacyDeriveHelpers { span : label_span } ) ;
159
+ lints:: LegacyDeriveHelpers { span : label_span } . decorate_lint ( diag ) ;
192
160
}
193
161
BuiltinLintDiag :: ProcMacroBackCompat { crate_name, fixed_version } => {
194
- ctx. emit_span_lint (
195
- lint,
196
- span,
197
- lints:: ProcMacroBackCompat { crate_name, fixed_version } ,
198
- ) ;
162
+ lints:: ProcMacroBackCompat { crate_name, fixed_version } . decorate_lint ( diag) ;
199
163
}
200
164
BuiltinLintDiag :: OrPatternsBackCompat ( suggestion_span, suggestion) => {
201
- ctx. emit_span_lint (
202
- lint,
203
- span,
204
- lints:: OrPatternsBackCompat { span : suggestion_span, suggestion } ,
205
- ) ;
165
+ lints:: OrPatternsBackCompat { span : suggestion_span, suggestion } . decorate_lint ( diag) ;
206
166
}
207
167
BuiltinLintDiag :: ReservedPrefix ( label_span, prefix) => {
208
- ctx. emit_span_lint (
209
- lint,
210
- span,
211
- lints:: ReservedPrefix {
212
- label : label_span,
213
- suggestion : label_span. shrink_to_hi ( ) ,
214
- prefix,
215
- } ,
216
- ) ;
168
+ lints:: ReservedPrefix {
169
+ label : label_span,
170
+ suggestion : label_span. shrink_to_hi ( ) ,
171
+ prefix,
172
+ }
173
+ . decorate_lint ( diag) ;
217
174
}
218
175
BuiltinLintDiag :: UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => {
219
- ctx. emit_span_lint (
220
- lint,
221
- span,
222
- lints:: UnusedBuiltinAttribute { invoc_span, attr_name, macro_name } ,
223
- ) ;
176
+ lints:: UnusedBuiltinAttribute { invoc_span, attr_name, macro_name } . decorate_lint ( diag) ;
224
177
}
225
178
BuiltinLintDiag :: TrailingMacro ( is_trailing, name) => {
226
- ctx . emit_span_lint ( lint , span , lints:: TrailingMacro { is_trailing, name } ) ;
179
+ lints:: TrailingMacro { is_trailing, name } . decorate_lint ( diag ) ;
227
180
}
228
181
BuiltinLintDiag :: BreakWithLabelAndLoop ( sugg_span) => {
229
- ctx. emit_span_lint (
230
- lint,
231
- span,
232
- lints:: BreakWithLabelAndLoop {
233
- sub : lints:: BreakWithLabelAndLoopSub {
234
- left : sugg_span. shrink_to_lo ( ) ,
235
- right : sugg_span. shrink_to_hi ( ) ,
236
- } ,
182
+ lints:: BreakWithLabelAndLoop {
183
+ sub : lints:: BreakWithLabelAndLoopSub {
184
+ left : sugg_span. shrink_to_lo ( ) ,
185
+ right : sugg_span. shrink_to_hi ( ) ,
237
186
} ,
238
- ) ;
187
+ }
188
+ . decorate_lint ( diag) ;
239
189
}
240
190
BuiltinLintDiag :: UnexpectedCfgName ( name, value) => {
241
- ctx . emit_span_lint ( lint , span , check_cfg:: unexpected_cfg_name ( sess, name, value) ) ;
191
+ check_cfg:: unexpected_cfg_name ( sess, name, value) . decorate_lint ( diag ) ;
242
192
}
243
193
BuiltinLintDiag :: UnexpectedCfgValue ( name, value) => {
244
- ctx . emit_span_lint ( lint , span , check_cfg:: unexpected_cfg_value ( sess, name, value) ) ;
194
+ check_cfg:: unexpected_cfg_value ( sess, name, value) . decorate_lint ( diag ) ;
245
195
}
246
196
BuiltinLintDiag :: DeprecatedWhereclauseLocation ( left_sp, sugg) => {
247
197
let suggestion = match sugg {
@@ -252,7 +202,7 @@ pub(super) fn emit_buffered_lint(
252
202
} ,
253
203
None => lints:: DeprecatedWhereClauseLocationSugg :: RemoveWhere { span : left_sp } ,
254
204
} ;
255
- ctx . emit_span_lint ( lint , span , lints:: DeprecatedWhereClauseLocation { suggestion } ) ;
205
+ lints:: DeprecatedWhereClauseLocation { suggestion } . decorate_lint ( diag ) ;
256
206
}
257
207
BuiltinLintDiag :: SingleUseLifetime {
258
208
param_span,
@@ -279,15 +229,12 @@ pub(super) fn emit_buffered_lint(
279
229
None
280
230
} ;
281
231
282
- ctx. emit_span_lint (
283
- lint,
284
- span,
285
- lints:: SingleUseLifetime { suggestion, param_span, use_span, ident } ,
286
- ) ;
232
+ lints:: SingleUseLifetime { suggestion, param_span, use_span, ident }
233
+ . decorate_lint ( diag) ;
287
234
}
288
235
BuiltinLintDiag :: SingleUseLifetime { use_span : None , deletion_span, ident, .. } => {
289
236
debug ! ( ?deletion_span) ;
290
- ctx . emit_span_lint ( lint , span , lints:: UnusedLifetime { deletion_span, ident } ) ;
237
+ lints:: UnusedLifetime { deletion_span, ident } . decorate_lint ( diag ) ;
291
238
}
292
239
BuiltinLintDiag :: NamedArgumentUsedPositionally {
293
240
position_sp_to_replace,
@@ -315,180 +262,156 @@ pub(super) fn emit_buffered_lint(
315
262
( None , String :: new ( ) )
316
263
} ;
317
264
318
- ctx. emit_span_lint (
319
- lint,
320
- span,
321
- lints:: NamedArgumentUsedPositionally {
322
- named_arg_sp,
323
- position_label_sp : position_sp_for_msg,
324
- suggestion,
325
- name,
326
- named_arg_name,
327
- } ,
328
- )
265
+ lints:: NamedArgumentUsedPositionally {
266
+ named_arg_sp,
267
+ position_label_sp : position_sp_for_msg,
268
+ suggestion,
269
+ name,
270
+ named_arg_name,
271
+ }
272
+ . decorate_lint ( diag) ;
329
273
}
330
274
BuiltinLintDiag :: ByteSliceInPackedStructWithDerive { ty } => {
331
- ctx . emit_span_lint ( lint , span , lints:: ByteSliceInPackedStructWithDerive { ty } )
275
+ lints:: ByteSliceInPackedStructWithDerive { ty } . decorate_lint ( diag ) ;
332
276
}
333
277
BuiltinLintDiag :: UnusedExternCrate { removal_span } => {
334
- ctx . emit_span_lint ( lint , span , lints:: UnusedExternCrate { removal_span } )
278
+ lints:: UnusedExternCrate { removal_span } . decorate_lint ( diag ) ;
335
279
}
336
280
BuiltinLintDiag :: ExternCrateNotIdiomatic { vis_span, ident_span } => {
337
281
let suggestion_span = vis_span. between ( ident_span) ;
338
282
let code = if vis_span. is_empty ( ) { "use " } else { " use " } ;
339
- ctx. emit_span_lint (
340
- lint,
341
- span,
342
- lints:: ExternCrateNotIdiomatic { span : suggestion_span, code } ,
343
- ) ;
283
+
284
+ lints:: ExternCrateNotIdiomatic { span : suggestion_span, code } . decorate_lint ( diag) ;
344
285
}
345
286
BuiltinLintDiag :: AmbiguousGlobImports { diag : ambiguity } => {
346
- ctx . emit_span_lint ( lint , span , lints:: AmbiguousGlobImports { ambiguity } ) ;
287
+ lints:: AmbiguousGlobImports { ambiguity } . decorate_lint ( diag ) ;
347
288
}
348
289
BuiltinLintDiag :: AmbiguousGlobReexports {
349
290
name,
350
291
namespace,
351
292
first_reexport_span,
352
293
duplicate_reexport_span,
353
294
} => {
354
- ctx. emit_span_lint (
355
- lint,
356
- span,
357
- lints:: AmbiguousGlobReexports {
358
- first_reexport : first_reexport_span,
359
- duplicate_reexport : duplicate_reexport_span,
360
- name,
361
- namespace,
362
- } ,
363
- ) ;
295
+ lints:: AmbiguousGlobReexports {
296
+ first_reexport : first_reexport_span,
297
+ duplicate_reexport : duplicate_reexport_span,
298
+ name,
299
+ namespace,
300
+ }
301
+ . decorate_lint ( diag) ;
364
302
}
365
303
BuiltinLintDiag :: HiddenGlobReexports {
366
304
name,
367
305
namespace,
368
306
glob_reexport_span,
369
307
private_item_span,
370
308
} => {
371
- ctx. emit_span_lint (
372
- lint,
373
- span,
374
- lints:: HiddenGlobReexports {
375
- glob_reexport : glob_reexport_span,
376
- private_item : private_item_span,
309
+ lints:: HiddenGlobReexports {
310
+ glob_reexport : glob_reexport_span,
311
+ private_item : private_item_span,
377
312
378
- name,
379
- namespace,
380
- } ,
381
- ) ;
313
+ name,
314
+ namespace,
315
+ }
316
+ . decorate_lint ( diag ) ;
382
317
}
383
318
BuiltinLintDiag :: UnusedQualifications { removal_span } => {
384
- ctx . emit_span_lint ( lint , span , lints:: UnusedQualifications { removal_span } ) ;
319
+ lints:: UnusedQualifications { removal_span } . decorate_lint ( diag ) ;
385
320
}
386
321
BuiltinLintDiag :: AssociatedConstElidedLifetime { elided, span : lt_span } => {
387
322
let lt_span = if elided { lt_span. shrink_to_hi ( ) } else { lt_span } ;
388
323
let code = if elided { "'static " } else { "'static" } ;
389
- ctx. emit_span_lint (
390
- lint,
391
- span,
392
- lints:: AssociatedConstElidedLifetime { span : lt_span, code, elided } ,
393
- ) ;
324
+ lints:: AssociatedConstElidedLifetime { span : lt_span, code, elided }
325
+ . decorate_lint ( diag) ;
394
326
}
395
327
BuiltinLintDiag :: RedundantImportVisibility { max_vis, span : vis_span, import_vis } => {
396
- ctx. emit_span_lint (
397
- lint,
398
- span,
399
- lints:: RedundantImportVisibility { span : vis_span, help : ( ) , max_vis, import_vis } ,
400
- ) ;
328
+ lints:: RedundantImportVisibility { span : vis_span, help : ( ) , max_vis, import_vis }
329
+ . decorate_lint ( diag) ;
401
330
}
402
331
BuiltinLintDiag :: UnknownDiagnosticAttribute { span : typo_span, typo_name } => {
403
332
let typo = typo_name. map ( |typo_name| lints:: UnknownDiagnosticAttributeTypoSugg {
404
333
span : typo_span,
405
334
typo_name,
406
335
} ) ;
407
- ctx . emit_span_lint ( lint , span , lints:: UnknownDiagnosticAttribute { typo } ) ;
336
+ lints:: UnknownDiagnosticAttribute { typo } . decorate_lint ( diag ) ;
408
337
}
409
338
BuiltinLintDiag :: MacroUseDeprecated => {
410
- ctx . emit_span_lint ( lint , span , lints:: MacroUseDeprecated )
339
+ lints:: MacroUseDeprecated . decorate_lint ( diag ) ;
411
340
}
412
- BuiltinLintDiag :: UnusedMacroUse => ctx . emit_span_lint ( lint , span , lints:: UnusedMacroUse ) ,
341
+ BuiltinLintDiag :: UnusedMacroUse => lints:: UnusedMacroUse . decorate_lint ( diag ) ,
413
342
BuiltinLintDiag :: PrivateExternCrateReexport ( ident) => {
414
- ctx . emit_span_lint ( lint , span , lints:: PrivateExternCrateReexport { ident } )
343
+ lints:: PrivateExternCrateReexport { ident } . decorate_lint ( diag ) ;
415
344
}
416
- BuiltinLintDiag :: UnusedLabel => ctx . emit_span_lint ( lint , span , lints:: UnusedLabel ) ,
345
+ BuiltinLintDiag :: UnusedLabel => lints:: UnusedLabel . decorate_lint ( diag ) ,
417
346
BuiltinLintDiag :: MacroIsPrivate ( ident) => {
418
- ctx . emit_span_lint ( lint , span , lints:: MacroIsPrivate { ident } )
347
+ lints:: MacroIsPrivate { ident } . decorate_lint ( diag ) ;
419
348
}
420
349
BuiltinLintDiag :: UnusedMacroDefinition ( name) => {
421
- ctx . emit_span_lint ( lint , span , lints:: UnusedMacroDefinition { name } )
350
+ lints:: UnusedMacroDefinition { name } . decorate_lint ( diag ) ;
422
351
}
423
352
BuiltinLintDiag :: MacroRuleNeverUsed ( n, name) => {
424
- ctx . emit_span_lint ( lint , span , lints:: MacroRuleNeverUsed { n : n + 1 , name } )
353
+ lints:: MacroRuleNeverUsed { n : n + 1 , name } . decorate_lint ( diag ) ;
425
354
}
426
355
BuiltinLintDiag :: UnstableFeature ( msg) => {
427
- ctx . emit_span_lint ( lint , span , lints:: UnstableFeature { msg } )
356
+ lints:: UnstableFeature { msg } . decorate_lint ( diag ) ;
428
357
}
429
358
BuiltinLintDiag :: AvoidUsingIntelSyntax => {
430
- ctx . emit_span_lint ( lint , span , lints:: AvoidIntelSyntax )
359
+ lints:: AvoidIntelSyntax . decorate_lint ( diag ) ;
431
360
}
432
361
BuiltinLintDiag :: AvoidUsingAttSyntax => {
433
- ctx . emit_span_lint ( lint , span , lints:: AvoidAttSyntax )
362
+ lints:: AvoidAttSyntax . decorate_lint ( diag ) ;
434
363
}
435
364
BuiltinLintDiag :: IncompleteInclude => {
436
- ctx . emit_span_lint ( lint , span , lints:: IncompleteInclude )
365
+ lints:: IncompleteInclude . decorate_lint ( diag ) ;
437
366
}
438
367
BuiltinLintDiag :: UnnameableTestItems => {
439
- ctx . emit_span_lint ( lint , span , lints:: UnnameableTestItems )
368
+ lints:: UnnameableTestItems . decorate_lint ( diag ) ;
440
369
}
441
370
BuiltinLintDiag :: DuplicateMacroAttribute => {
442
- ctx . emit_span_lint ( lint , span , lints:: DuplicateMacroAttribute )
371
+ lints:: DuplicateMacroAttribute . decorate_lint ( diag ) ;
443
372
}
444
373
BuiltinLintDiag :: CfgAttrNoAttributes => {
445
- ctx . emit_span_lint ( lint , span , lints:: CfgAttrNoAttributes )
374
+ lints:: CfgAttrNoAttributes . decorate_lint ( diag ) ;
446
375
}
447
376
BuiltinLintDiag :: CrateTypeInCfgAttr => {
448
- ctx . emit_span_lint ( lint , span , lints:: CrateTypeInCfgAttr )
377
+ lints:: CrateTypeInCfgAttr . decorate_lint ( diag ) ;
449
378
}
450
379
BuiltinLintDiag :: CrateNameInCfgAttr => {
451
- ctx . emit_span_lint ( lint , span , lints:: CrateNameInCfgAttr )
380
+ lints:: CrateNameInCfgAttr . decorate_lint ( diag ) ;
452
381
}
453
382
BuiltinLintDiag :: MissingFragmentSpecifier => {
454
- ctx . emit_span_lint ( lint , span , lints:: MissingFragmentSpecifier )
383
+ lints:: MissingFragmentSpecifier . decorate_lint ( diag ) ;
455
384
}
456
385
BuiltinLintDiag :: MetaVariableStillRepeating ( name) => {
457
- ctx . emit_span_lint ( lint , span , lints:: MetaVariableStillRepeating { name } )
386
+ lints:: MetaVariableStillRepeating { name } . decorate_lint ( diag ) ;
458
387
}
459
388
BuiltinLintDiag :: MetaVariableWrongOperator => {
460
- ctx . emit_span_lint ( lint , span , lints:: MetaVariableWrongOperator )
389
+ lints:: MetaVariableWrongOperator . decorate_lint ( diag ) ;
461
390
}
462
391
BuiltinLintDiag :: DuplicateMatcherBinding => {
463
- ctx . emit_span_lint ( lint , span , lints:: DuplicateMatcherBinding )
392
+ lints:: DuplicateMatcherBinding . decorate_lint ( diag ) ;
464
393
}
465
394
BuiltinLintDiag :: UnknownMacroVariable ( name) => {
466
- ctx. emit_span_lint ( lint, span, lints:: UnknownMacroVariable { name } )
467
- }
468
- BuiltinLintDiag :: UnusedCrateDependency { extern_crate, local_crate } => ctx. emit_span_lint (
469
- lint,
470
- span,
471
- lints:: UnusedCrateDependency { extern_crate, local_crate } ,
472
- ) ,
473
- BuiltinLintDiag :: WasmCAbi => ctx. emit_span_lint ( lint, span, lints:: WasmCAbi ) ,
474
- BuiltinLintDiag :: IllFormedAttributeInput { suggestions } => ctx. emit_span_lint (
475
- lint,
476
- span,
395
+ lints:: UnknownMacroVariable { name } . decorate_lint ( diag) ;
396
+ }
397
+ BuiltinLintDiag :: UnusedCrateDependency { extern_crate, local_crate } => {
398
+ lints:: UnusedCrateDependency { extern_crate, local_crate } . decorate_lint ( diag)
399
+ }
400
+ BuiltinLintDiag :: WasmCAbi => lints:: WasmCAbi . decorate_lint ( diag) ,
401
+ BuiltinLintDiag :: IllFormedAttributeInput { suggestions } => {
477
402
lints:: IllFormedAttributeInput {
478
403
num_suggestions : suggestions. len ( ) ,
479
404
suggestions : DiagArgValue :: StrListSepByAnd (
480
405
suggestions. into_iter ( ) . map ( |s| format ! ( "`{s}`" ) . into ( ) ) . collect ( ) ,
481
406
) ,
482
- } ,
483
- ) ,
484
- BuiltinLintDiag :: InnerAttributeUnstable { is_macro } => ctx. emit_span_lint (
485
- lint,
486
- span,
487
- if is_macro {
488
- lints:: InnerAttributeUnstable :: InnerMacroAttribute
489
- } else {
490
- lints:: InnerAttributeUnstable :: CustomInnerAttribute
491
- } ,
492
- ) ,
407
+ }
408
+ . decorate_lint ( diag)
409
+ }
410
+ BuiltinLintDiag :: InnerAttributeUnstable { is_macro } => if is_macro {
411
+ lints:: InnerAttributeUnstable :: InnerMacroAttribute
412
+ } else {
413
+ lints:: InnerAttributeUnstable :: CustomInnerAttribute
414
+ }
415
+ . decorate_lint ( diag) ,
493
416
}
494
417
}
0 commit comments