Skip to content

Commit 37bf2d2

Browse files
committedMay 23, 2024··
Delay the construction of early lint diag structs
Fixes a slew of perf regressions.
1 parent 9f67c50 commit 37bf2d2

File tree

2 files changed

+156
-231
lines changed

2 files changed

+156
-231
lines changed
 

‎compiler/rustc_lint/src/context.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,9 @@ impl EarlyContext<'_> {
539539
span: MultiSpan,
540540
diagnostic: BuiltinLintDiag,
541541
) {
542-
diagnostics::emit_buffered_lint(self, lint, span, diagnostic)
542+
self.opt_span_lint(lint, Some(span), |diag| {
543+
diagnostics::decorate_lint(self.sess(), diagnostic, diag);
544+
});
543545
}
544546
}
545547

‎compiler/rustc_lint/src/context/diagnostics.rs

+153-230
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,18 @@
44
use std::borrow::Cow;
55

66
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};
99
use rustc_middle::middle::stability;
10-
use rustc_session::lint::{BuiltinLintDiag, Lint};
10+
use rustc_session::lint::BuiltinLintDiag;
11+
use rustc_session::Session;
1112
use rustc_span::BytePos;
1213

13-
use crate::{lints, EarlyContext, LintContext as _};
14+
use crate::lints;
1415

1516
mod check_cfg;
1617

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<'_, ()>) {
2419
match diagnostic {
2520
BuiltinLintDiag::UnicodeTextFlow(comment_span, content) => {
2621
let spans: Vec<_> = content
@@ -39,16 +34,14 @@ pub(super) fn emit_buffered_lint(
3934
let suggestions = (!spans.is_empty()).then_some(lints::UnicodeTextFlowSuggestion {
4035
spans: spans.iter().map(|(_c, span)| *span).collect(),
4136
});
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);
5245
}
5346
BuiltinLintDiag::AbsPathWithModule(mod_span) => {
5447
let (replacement, applicability) = match sess.source_map().span_to_snippet(mod_span) {
@@ -61,48 +54,35 @@ pub(super) fn emit_buffered_lint(
6154
}
6255
Err(_) => ("crate::<path>".to_string(), Applicability::HasPlaceholders),
6356
};
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+
8871
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);
10282
}
10383
BuiltinLintDiag::UnknownCrateTypes { span, candidate } => {
10484
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);
10686
}
10787
BuiltinLintDiag::UnusedImports {
10888
remove_whole_use,
@@ -119,18 +99,15 @@ pub(super) fn emit_buffered_lint(
11999
let test_module_span =
120100
test_module_span.map(|span| sess.source_map().guess_head_span(span));
121101

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);
134111
}
135112
BuiltinLintDiag::RedundantImport(spans, ident) => {
136113
let subs = spans
@@ -144,7 +121,7 @@ pub(super) fn emit_buffered_lint(
144121
})(span)
145122
})
146123
.collect();
147-
ctx.emit_span_lint(lint, span, lints::RedundantImport { subs, ident });
124+
lints::RedundantImport { subs, ident }.decorate_lint(diag);
148125
}
149126
BuiltinLintDiag::DeprecatedMacro {
150127
suggestion,
@@ -158,90 +135,63 @@ pub(super) fn emit_buffered_lint(
158135
kind: "macro".to_owned(),
159136
suggestion,
160137
});
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);
166141
}
167142
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);
169144
}
170145
BuiltinLintDiag::PatternsInFnsWithoutBody { span: remove_span, ident, is_foreign } => {
171146
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);
182153
}
183154
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);
189157
}
190158
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);
192160
}
193161
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);
199163
}
200164
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);
206166
}
207167
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);
217174
}
218175
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);
224177
}
225178
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);
227180
}
228181
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(),
237186
},
238-
);
187+
}
188+
.decorate_lint(diag);
239189
}
240190
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);
242192
}
243193
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);
245195
}
246196
BuiltinLintDiag::DeprecatedWhereclauseLocation(left_sp, sugg) => {
247197
let suggestion = match sugg {
@@ -252,7 +202,7 @@ pub(super) fn emit_buffered_lint(
252202
},
253203
None => lints::DeprecatedWhereClauseLocationSugg::RemoveWhere { span: left_sp },
254204
};
255-
ctx.emit_span_lint(lint, span, lints::DeprecatedWhereClauseLocation { suggestion });
205+
lints::DeprecatedWhereClauseLocation { suggestion }.decorate_lint(diag);
256206
}
257207
BuiltinLintDiag::SingleUseLifetime {
258208
param_span,
@@ -279,15 +229,12 @@ pub(super) fn emit_buffered_lint(
279229
None
280230
};
281231

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);
287234
}
288235
BuiltinLintDiag::SingleUseLifetime { use_span: None, deletion_span, ident, .. } => {
289236
debug!(?deletion_span);
290-
ctx.emit_span_lint(lint, span, lints::UnusedLifetime { deletion_span, ident });
237+
lints::UnusedLifetime { deletion_span, ident }.decorate_lint(diag);
291238
}
292239
BuiltinLintDiag::NamedArgumentUsedPositionally {
293240
position_sp_to_replace,
@@ -315,180 +262,156 @@ pub(super) fn emit_buffered_lint(
315262
(None, String::new())
316263
};
317264

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);
329273
}
330274
BuiltinLintDiag::ByteSliceInPackedStructWithDerive { ty } => {
331-
ctx.emit_span_lint(lint, span, lints::ByteSliceInPackedStructWithDerive { ty })
275+
lints::ByteSliceInPackedStructWithDerive { ty }.decorate_lint(diag);
332276
}
333277
BuiltinLintDiag::UnusedExternCrate { removal_span } => {
334-
ctx.emit_span_lint(lint, span, lints::UnusedExternCrate { removal_span })
278+
lints::UnusedExternCrate { removal_span }.decorate_lint(diag);
335279
}
336280
BuiltinLintDiag::ExternCrateNotIdiomatic { vis_span, ident_span } => {
337281
let suggestion_span = vis_span.between(ident_span);
338282
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);
344285
}
345286
BuiltinLintDiag::AmbiguousGlobImports { diag: ambiguity } => {
346-
ctx.emit_span_lint(lint, span, lints::AmbiguousGlobImports { ambiguity });
287+
lints::AmbiguousGlobImports { ambiguity }.decorate_lint(diag);
347288
}
348289
BuiltinLintDiag::AmbiguousGlobReexports {
349290
name,
350291
namespace,
351292
first_reexport_span,
352293
duplicate_reexport_span,
353294
} => {
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);
364302
}
365303
BuiltinLintDiag::HiddenGlobReexports {
366304
name,
367305
namespace,
368306
glob_reexport_span,
369307
private_item_span,
370308
} => {
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,
377312

378-
name,
379-
namespace,
380-
},
381-
);
313+
name,
314+
namespace,
315+
}
316+
.decorate_lint(diag);
382317
}
383318
BuiltinLintDiag::UnusedQualifications { removal_span } => {
384-
ctx.emit_span_lint(lint, span, lints::UnusedQualifications { removal_span });
319+
lints::UnusedQualifications { removal_span }.decorate_lint(diag);
385320
}
386321
BuiltinLintDiag::AssociatedConstElidedLifetime { elided, span: lt_span } => {
387322
let lt_span = if elided { lt_span.shrink_to_hi() } else { lt_span };
388323
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);
394326
}
395327
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);
401330
}
402331
BuiltinLintDiag::UnknownDiagnosticAttribute { span: typo_span, typo_name } => {
403332
let typo = typo_name.map(|typo_name| lints::UnknownDiagnosticAttributeTypoSugg {
404333
span: typo_span,
405334
typo_name,
406335
});
407-
ctx.emit_span_lint(lint, span, lints::UnknownDiagnosticAttribute { typo });
336+
lints::UnknownDiagnosticAttribute { typo }.decorate_lint(diag);
408337
}
409338
BuiltinLintDiag::MacroUseDeprecated => {
410-
ctx.emit_span_lint(lint, span, lints::MacroUseDeprecated)
339+
lints::MacroUseDeprecated.decorate_lint(diag);
411340
}
412-
BuiltinLintDiag::UnusedMacroUse => ctx.emit_span_lint(lint, span, lints::UnusedMacroUse),
341+
BuiltinLintDiag::UnusedMacroUse => lints::UnusedMacroUse.decorate_lint(diag),
413342
BuiltinLintDiag::PrivateExternCrateReexport(ident) => {
414-
ctx.emit_span_lint(lint, span, lints::PrivateExternCrateReexport { ident })
343+
lints::PrivateExternCrateReexport { ident }.decorate_lint(diag);
415344
}
416-
BuiltinLintDiag::UnusedLabel => ctx.emit_span_lint(lint, span, lints::UnusedLabel),
345+
BuiltinLintDiag::UnusedLabel => lints::UnusedLabel.decorate_lint(diag),
417346
BuiltinLintDiag::MacroIsPrivate(ident) => {
418-
ctx.emit_span_lint(lint, span, lints::MacroIsPrivate { ident })
347+
lints::MacroIsPrivate { ident }.decorate_lint(diag);
419348
}
420349
BuiltinLintDiag::UnusedMacroDefinition(name) => {
421-
ctx.emit_span_lint(lint, span, lints::UnusedMacroDefinition { name })
350+
lints::UnusedMacroDefinition { name }.decorate_lint(diag);
422351
}
423352
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);
425354
}
426355
BuiltinLintDiag::UnstableFeature(msg) => {
427-
ctx.emit_span_lint(lint, span, lints::UnstableFeature { msg })
356+
lints::UnstableFeature { msg }.decorate_lint(diag);
428357
}
429358
BuiltinLintDiag::AvoidUsingIntelSyntax => {
430-
ctx.emit_span_lint(lint, span, lints::AvoidIntelSyntax)
359+
lints::AvoidIntelSyntax.decorate_lint(diag);
431360
}
432361
BuiltinLintDiag::AvoidUsingAttSyntax => {
433-
ctx.emit_span_lint(lint, span, lints::AvoidAttSyntax)
362+
lints::AvoidAttSyntax.decorate_lint(diag);
434363
}
435364
BuiltinLintDiag::IncompleteInclude => {
436-
ctx.emit_span_lint(lint, span, lints::IncompleteInclude)
365+
lints::IncompleteInclude.decorate_lint(diag);
437366
}
438367
BuiltinLintDiag::UnnameableTestItems => {
439-
ctx.emit_span_lint(lint, span, lints::UnnameableTestItems)
368+
lints::UnnameableTestItems.decorate_lint(diag);
440369
}
441370
BuiltinLintDiag::DuplicateMacroAttribute => {
442-
ctx.emit_span_lint(lint, span, lints::DuplicateMacroAttribute)
371+
lints::DuplicateMacroAttribute.decorate_lint(diag);
443372
}
444373
BuiltinLintDiag::CfgAttrNoAttributes => {
445-
ctx.emit_span_lint(lint, span, lints::CfgAttrNoAttributes)
374+
lints::CfgAttrNoAttributes.decorate_lint(diag);
446375
}
447376
BuiltinLintDiag::CrateTypeInCfgAttr => {
448-
ctx.emit_span_lint(lint, span, lints::CrateTypeInCfgAttr)
377+
lints::CrateTypeInCfgAttr.decorate_lint(diag);
449378
}
450379
BuiltinLintDiag::CrateNameInCfgAttr => {
451-
ctx.emit_span_lint(lint, span, lints::CrateNameInCfgAttr)
380+
lints::CrateNameInCfgAttr.decorate_lint(diag);
452381
}
453382
BuiltinLintDiag::MissingFragmentSpecifier => {
454-
ctx.emit_span_lint(lint, span, lints::MissingFragmentSpecifier)
383+
lints::MissingFragmentSpecifier.decorate_lint(diag);
455384
}
456385
BuiltinLintDiag::MetaVariableStillRepeating(name) => {
457-
ctx.emit_span_lint(lint, span, lints::MetaVariableStillRepeating { name })
386+
lints::MetaVariableStillRepeating { name }.decorate_lint(diag);
458387
}
459388
BuiltinLintDiag::MetaVariableWrongOperator => {
460-
ctx.emit_span_lint(lint, span, lints::MetaVariableWrongOperator)
389+
lints::MetaVariableWrongOperator.decorate_lint(diag);
461390
}
462391
BuiltinLintDiag::DuplicateMatcherBinding => {
463-
ctx.emit_span_lint(lint, span, lints::DuplicateMatcherBinding)
392+
lints::DuplicateMatcherBinding.decorate_lint(diag);
464393
}
465394
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 } => {
477402
lints::IllFormedAttributeInput {
478403
num_suggestions: suggestions.len(),
479404
suggestions: DiagArgValue::StrListSepByAnd(
480405
suggestions.into_iter().map(|s| format!("`{s}`").into()).collect(),
481406
),
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),
493416
}
494417
}

0 commit comments

Comments
 (0)
Please sign in to comment.