Delay the construction of early lint diag structs

Fixes a slew of perf regressions.
This commit is contained in:
León Orell Valerian Liehr 2024-05-22 17:03:25 +02:00
parent 9f67c50128
commit 37bf2d2dab
No known key found for this signature in database
GPG Key ID: D17A07215F68E713
2 changed files with 154 additions and 229 deletions

View File

@ -539,7 +539,9 @@ pub fn span_lint_with_diagnostics(
span: MultiSpan, span: MultiSpan,
diagnostic: BuiltinLintDiag, diagnostic: BuiltinLintDiag,
) { ) {
diagnostics::emit_buffered_lint(self, lint, span, diagnostic) self.opt_span_lint(lint, Some(span), |diag| {
diagnostics::decorate_lint(self.sess(), diagnostic, diag);
});
} }
} }

View File

@ -4,23 +4,18 @@
use std::borrow::Cow; use std::borrow::Cow;
use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS; use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS;
use rustc_errors::Applicability; use rustc_errors::elided_lifetime_in_path_suggestion;
use rustc_errors::{elided_lifetime_in_path_suggestion, DiagArgValue, MultiSpan}; use rustc_errors::{Applicability, Diag, DiagArgValue, LintDiagnostic};
use rustc_middle::middle::stability; use rustc_middle::middle::stability;
use rustc_session::lint::{BuiltinLintDiag, Lint}; use rustc_session::lint::BuiltinLintDiag;
use rustc_session::Session;
use rustc_span::BytePos; use rustc_span::BytePos;
use crate::{lints, EarlyContext, LintContext as _}; use crate::lints;
mod check_cfg; mod check_cfg;
pub(super) fn emit_buffered_lint( pub(super) fn decorate_lint(sess: &Session, diagnostic: BuiltinLintDiag, diag: &mut Diag<'_, ()>) {
ctx: &EarlyContext<'_>,
lint: &'static Lint,
span: MultiSpan,
diagnostic: BuiltinLintDiag,
) {
let sess = ctx.sess();
match diagnostic { match diagnostic {
BuiltinLintDiag::UnicodeTextFlow(comment_span, content) => { BuiltinLintDiag::UnicodeTextFlow(comment_span, content) => {
let spans: Vec<_> = content let spans: Vec<_> = content
@ -39,16 +34,14 @@ pub(super) fn emit_buffered_lint(
let suggestions = (!spans.is_empty()).then_some(lints::UnicodeTextFlowSuggestion { let suggestions = (!spans.is_empty()).then_some(lints::UnicodeTextFlowSuggestion {
spans: spans.iter().map(|(_c, span)| *span).collect(), spans: spans.iter().map(|(_c, span)| *span).collect(),
}); });
ctx.emit_span_lint(
lint, lints::UnicodeTextFlow {
span, comment_span,
lints::UnicodeTextFlow { characters,
comment_span, suggestions,
characters, num_codepoints: spans.len(),
suggestions, }
num_codepoints: spans.len(), .decorate_lint(diag);
},
)
} }
BuiltinLintDiag::AbsPathWithModule(mod_span) => { BuiltinLintDiag::AbsPathWithModule(mod_span) => {
let (replacement, applicability) = match sess.source_map().span_to_snippet(mod_span) { let (replacement, applicability) = match sess.source_map().span_to_snippet(mod_span) {
@ -61,48 +54,35 @@ pub(super) fn emit_buffered_lint(
} }
Err(_) => ("crate::<path>".to_string(), Applicability::HasPlaceholders), Err(_) => ("crate::<path>".to_string(), Applicability::HasPlaceholders),
}; };
ctx.emit_span_lint( lints::AbsPathWithModule {
lint, sugg: lints::AbsPathWithModuleSugg { span: mod_span, applicability, replacement },
span, }
lints::AbsPathWithModule { .decorate_lint(diag);
sugg: lints::AbsPathWithModuleSugg {
span: mod_span,
applicability,
replacement,
},
},
);
} }
BuiltinLintDiag::ProcMacroDeriveResolutionFallback { span: macro_span, ns, ident } => ctx BuiltinLintDiag::ProcMacroDeriveResolutionFallback { span: macro_span, ns, ident } => {
.emit_span_lint( lints::ProcMacroDeriveResolutionFallback { span: macro_span, ns, ident }
lint, .decorate_lint(diag)
span, }
lints::ProcMacroDeriveResolutionFallback { span: macro_span, ns, ident }, BuiltinLintDiag::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => {
), lints::MacroExpandedMacroExportsAccessedByAbsolutePaths { definition: span_def }
BuiltinLintDiag::MacroExpandedMacroExportsAccessedByAbsolutePaths(span_def) => ctx .decorate_lint(diag)
.emit_span_lint( }
lint,
span,
lints::MacroExpandedMacroExportsAccessedByAbsolutePaths { definition: span_def },
),
BuiltinLintDiag::ElidedLifetimesInPaths(n, path_span, incl_angl_brckt, insertion_span) => { BuiltinLintDiag::ElidedLifetimesInPaths(n, path_span, incl_angl_brckt, insertion_span) => {
ctx.emit_span_lint( lints::ElidedLifetimesInPaths {
lint, subdiag: elided_lifetime_in_path_suggestion(
span, sess.source_map(),
lints::ElidedLifetimesInPaths { n,
subdiag: elided_lifetime_in_path_suggestion( path_span,
sess.source_map(), incl_angl_brckt,
n, insertion_span,
path_span, ),
incl_angl_brckt, }
insertion_span, .decorate_lint(diag);
),
},
);
} }
BuiltinLintDiag::UnknownCrateTypes { span, candidate } => { BuiltinLintDiag::UnknownCrateTypes { span, candidate } => {
let sugg = candidate.map(|candidate| lints::UnknownCrateTypesSub { span, candidate }); let sugg = candidate.map(|candidate| lints::UnknownCrateTypesSub { span, candidate });
ctx.emit_span_lint(lint, span, lints::UnknownCrateTypes { sugg }); lints::UnknownCrateTypes { sugg }.decorate_lint(diag);
} }
BuiltinLintDiag::UnusedImports { BuiltinLintDiag::UnusedImports {
remove_whole_use, remove_whole_use,
@ -119,18 +99,15 @@ pub(super) fn emit_buffered_lint(
let test_module_span = let test_module_span =
test_module_span.map(|span| sess.source_map().guess_head_span(span)); test_module_span.map(|span| sess.source_map().guess_head_span(span));
ctx.emit_span_lint( lints::UnusedImports {
lint, sugg,
span, test_module_span,
lints::UnusedImports { num_snippets: span_snippets.len(),
sugg, span_snippets: DiagArgValue::StrListSepByAnd(
test_module_span, span_snippets.into_iter().map(Cow::Owned).collect(),
num_snippets: span_snippets.len(), ),
span_snippets: DiagArgValue::StrListSepByAnd( }
span_snippets.into_iter().map(Cow::Owned).collect(), .decorate_lint(diag);
),
},
);
} }
BuiltinLintDiag::RedundantImport(spans, ident) => { BuiltinLintDiag::RedundantImport(spans, ident) => {
let subs = spans let subs = spans
@ -144,7 +121,7 @@ pub(super) fn emit_buffered_lint(
})(span) })(span)
}) })
.collect(); .collect();
ctx.emit_span_lint(lint, span, lints::RedundantImport { subs, ident }); lints::RedundantImport { subs, ident }.decorate_lint(diag);
} }
BuiltinLintDiag::DeprecatedMacro { BuiltinLintDiag::DeprecatedMacro {
suggestion, suggestion,
@ -158,90 +135,63 @@ pub(super) fn emit_buffered_lint(
kind: "macro".to_owned(), kind: "macro".to_owned(),
suggestion, suggestion,
}); });
ctx.emit_span_lint(
lint, stability::Deprecated { sub, kind: "macro".to_owned(), path, note, since_kind }
span, .decorate_lint(diag);
stability::Deprecated { sub, kind: "macro".to_owned(), path, note, since_kind },
);
} }
BuiltinLintDiag::UnusedDocComment(attr_span) => { BuiltinLintDiag::UnusedDocComment(attr_span) => {
ctx.emit_span_lint(lint, span, lints::UnusedDocComment { span: attr_span }); lints::UnusedDocComment { span: attr_span }.decorate_lint(diag);
} }
BuiltinLintDiag::PatternsInFnsWithoutBody { span: remove_span, ident, is_foreign } => { BuiltinLintDiag::PatternsInFnsWithoutBody { span: remove_span, ident, is_foreign } => {
let sub = lints::PatternsInFnsWithoutBodySub { ident, span: remove_span }; let sub = lints::PatternsInFnsWithoutBodySub { ident, span: remove_span };
if is_foreign {
ctx.emit_span_lint( lints::PatternsInFnsWithoutBody::Foreign { sub }
lint, } else {
span, lints::PatternsInFnsWithoutBody::Bodiless { sub }
if is_foreign { }
lints::PatternsInFnsWithoutBody::Foreign { sub } .decorate_lint(diag);
} else {
lints::PatternsInFnsWithoutBody::Bodiless { sub }
},
);
} }
BuiltinLintDiag::MissingAbi(label_span, default_abi) => { BuiltinLintDiag::MissingAbi(label_span, default_abi) => {
ctx.emit_span_lint( lints::MissingAbi { span: label_span, default_abi: default_abi.name() }
lint, .decorate_lint(diag);
span,
lints::MissingAbi { span: label_span, default_abi: default_abi.name() },
);
} }
BuiltinLintDiag::LegacyDeriveHelpers(label_span) => { BuiltinLintDiag::LegacyDeriveHelpers(label_span) => {
ctx.emit_span_lint(lint, span, lints::LegacyDeriveHelpers { span: label_span }); lints::LegacyDeriveHelpers { span: label_span }.decorate_lint(diag);
} }
BuiltinLintDiag::ProcMacroBackCompat { crate_name, fixed_version } => { BuiltinLintDiag::ProcMacroBackCompat { crate_name, fixed_version } => {
ctx.emit_span_lint( lints::ProcMacroBackCompat { crate_name, fixed_version }.decorate_lint(diag);
lint,
span,
lints::ProcMacroBackCompat { crate_name, fixed_version },
);
} }
BuiltinLintDiag::OrPatternsBackCompat(suggestion_span, suggestion) => { BuiltinLintDiag::OrPatternsBackCompat(suggestion_span, suggestion) => {
ctx.emit_span_lint( lints::OrPatternsBackCompat { span: suggestion_span, suggestion }.decorate_lint(diag);
lint,
span,
lints::OrPatternsBackCompat { span: suggestion_span, suggestion },
);
} }
BuiltinLintDiag::ReservedPrefix(label_span, prefix) => { BuiltinLintDiag::ReservedPrefix(label_span, prefix) => {
ctx.emit_span_lint( lints::ReservedPrefix {
lint, label: label_span,
span, suggestion: label_span.shrink_to_hi(),
lints::ReservedPrefix { prefix,
label: label_span, }
suggestion: label_span.shrink_to_hi(), .decorate_lint(diag);
prefix,
},
);
} }
BuiltinLintDiag::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => { BuiltinLintDiag::UnusedBuiltinAttribute { attr_name, macro_name, invoc_span } => {
ctx.emit_span_lint( lints::UnusedBuiltinAttribute { invoc_span, attr_name, macro_name }.decorate_lint(diag);
lint,
span,
lints::UnusedBuiltinAttribute { invoc_span, attr_name, macro_name },
);
} }
BuiltinLintDiag::TrailingMacro(is_trailing, name) => { BuiltinLintDiag::TrailingMacro(is_trailing, name) => {
ctx.emit_span_lint(lint, span, lints::TrailingMacro { is_trailing, name }); lints::TrailingMacro { is_trailing, name }.decorate_lint(diag);
} }
BuiltinLintDiag::BreakWithLabelAndLoop(sugg_span) => { BuiltinLintDiag::BreakWithLabelAndLoop(sugg_span) => {
ctx.emit_span_lint( lints::BreakWithLabelAndLoop {
lint, sub: lints::BreakWithLabelAndLoopSub {
span, left: sugg_span.shrink_to_lo(),
lints::BreakWithLabelAndLoop { right: sugg_span.shrink_to_hi(),
sub: lints::BreakWithLabelAndLoopSub {
left: sugg_span.shrink_to_lo(),
right: sugg_span.shrink_to_hi(),
},
}, },
); }
.decorate_lint(diag);
} }
BuiltinLintDiag::UnexpectedCfgName(name, value) => { BuiltinLintDiag::UnexpectedCfgName(name, value) => {
ctx.emit_span_lint(lint, span, check_cfg::unexpected_cfg_name(sess, name, value)); check_cfg::unexpected_cfg_name(sess, name, value).decorate_lint(diag);
} }
BuiltinLintDiag::UnexpectedCfgValue(name, value) => { BuiltinLintDiag::UnexpectedCfgValue(name, value) => {
ctx.emit_span_lint(lint, span, check_cfg::unexpected_cfg_value(sess, name, value)); check_cfg::unexpected_cfg_value(sess, name, value).decorate_lint(diag);
} }
BuiltinLintDiag::DeprecatedWhereclauseLocation(left_sp, sugg) => { BuiltinLintDiag::DeprecatedWhereclauseLocation(left_sp, sugg) => {
let suggestion = match sugg { let suggestion = match sugg {
@ -252,7 +202,7 @@ pub(super) fn emit_buffered_lint(
}, },
None => lints::DeprecatedWhereClauseLocationSugg::RemoveWhere { span: left_sp }, None => lints::DeprecatedWhereClauseLocationSugg::RemoveWhere { span: left_sp },
}; };
ctx.emit_span_lint(lint, span, lints::DeprecatedWhereClauseLocation { suggestion }); lints::DeprecatedWhereClauseLocation { suggestion }.decorate_lint(diag);
} }
BuiltinLintDiag::SingleUseLifetime { BuiltinLintDiag::SingleUseLifetime {
param_span, param_span,
@ -279,15 +229,12 @@ pub(super) fn emit_buffered_lint(
None None
}; };
ctx.emit_span_lint( lints::SingleUseLifetime { suggestion, param_span, use_span, ident }
lint, .decorate_lint(diag);
span,
lints::SingleUseLifetime { suggestion, param_span, use_span, ident },
);
} }
BuiltinLintDiag::SingleUseLifetime { use_span: None, deletion_span, ident, .. } => { BuiltinLintDiag::SingleUseLifetime { use_span: None, deletion_span, ident, .. } => {
debug!(?deletion_span); debug!(?deletion_span);
ctx.emit_span_lint(lint, span, lints::UnusedLifetime { deletion_span, ident }); lints::UnusedLifetime { deletion_span, ident }.decorate_lint(diag);
} }
BuiltinLintDiag::NamedArgumentUsedPositionally { BuiltinLintDiag::NamedArgumentUsedPositionally {
position_sp_to_replace, position_sp_to_replace,
@ -315,35 +262,29 @@ pub(super) fn emit_buffered_lint(
(None, String::new()) (None, String::new())
}; };
ctx.emit_span_lint( lints::NamedArgumentUsedPositionally {
lint, named_arg_sp,
span, position_label_sp: position_sp_for_msg,
lints::NamedArgumentUsedPositionally { suggestion,
named_arg_sp, name,
position_label_sp: position_sp_for_msg, named_arg_name,
suggestion, }
name, .decorate_lint(diag);
named_arg_name,
},
)
} }
BuiltinLintDiag::ByteSliceInPackedStructWithDerive { ty } => { BuiltinLintDiag::ByteSliceInPackedStructWithDerive { ty } => {
ctx.emit_span_lint(lint, span, lints::ByteSliceInPackedStructWithDerive { ty }) lints::ByteSliceInPackedStructWithDerive { ty }.decorate_lint(diag);
} }
BuiltinLintDiag::UnusedExternCrate { removal_span } => { BuiltinLintDiag::UnusedExternCrate { removal_span } => {
ctx.emit_span_lint(lint, span, lints::UnusedExternCrate { removal_span }) lints::UnusedExternCrate { removal_span }.decorate_lint(diag);
} }
BuiltinLintDiag::ExternCrateNotIdiomatic { vis_span, ident_span } => { BuiltinLintDiag::ExternCrateNotIdiomatic { vis_span, ident_span } => {
let suggestion_span = vis_span.between(ident_span); let suggestion_span = vis_span.between(ident_span);
let code = if vis_span.is_empty() { "use " } else { " use " }; let code = if vis_span.is_empty() { "use " } else { " use " };
ctx.emit_span_lint(
lint, lints::ExternCrateNotIdiomatic { span: suggestion_span, code }.decorate_lint(diag);
span,
lints::ExternCrateNotIdiomatic { span: suggestion_span, code },
);
} }
BuiltinLintDiag::AmbiguousGlobImports { diag: ambiguity } => { BuiltinLintDiag::AmbiguousGlobImports { diag: ambiguity } => {
ctx.emit_span_lint(lint, span, lints::AmbiguousGlobImports { ambiguity }); lints::AmbiguousGlobImports { ambiguity }.decorate_lint(diag);
} }
BuiltinLintDiag::AmbiguousGlobReexports { BuiltinLintDiag::AmbiguousGlobReexports {
name, name,
@ -351,16 +292,13 @@ pub(super) fn emit_buffered_lint(
first_reexport_span, first_reexport_span,
duplicate_reexport_span, duplicate_reexport_span,
} => { } => {
ctx.emit_span_lint( lints::AmbiguousGlobReexports {
lint, first_reexport: first_reexport_span,
span, duplicate_reexport: duplicate_reexport_span,
lints::AmbiguousGlobReexports { name,
first_reexport: first_reexport_span, namespace,
duplicate_reexport: duplicate_reexport_span, }
name, .decorate_lint(diag);
namespace,
},
);
} }
BuiltinLintDiag::HiddenGlobReexports { BuiltinLintDiag::HiddenGlobReexports {
name, name,
@ -368,127 +306,112 @@ pub(super) fn emit_buffered_lint(
glob_reexport_span, glob_reexport_span,
private_item_span, private_item_span,
} => { } => {
ctx.emit_span_lint( lints::HiddenGlobReexports {
lint, glob_reexport: glob_reexport_span,
span, private_item: private_item_span,
lints::HiddenGlobReexports {
glob_reexport: glob_reexport_span,
private_item: private_item_span,
name, name,
namespace, namespace,
}, }
); .decorate_lint(diag);
} }
BuiltinLintDiag::UnusedQualifications { removal_span } => { BuiltinLintDiag::UnusedQualifications { removal_span } => {
ctx.emit_span_lint(lint, span, lints::UnusedQualifications { removal_span }); lints::UnusedQualifications { removal_span }.decorate_lint(diag);
} }
BuiltinLintDiag::AssociatedConstElidedLifetime { elided, span: lt_span } => { BuiltinLintDiag::AssociatedConstElidedLifetime { elided, span: lt_span } => {
let lt_span = if elided { lt_span.shrink_to_hi() } else { lt_span }; let lt_span = if elided { lt_span.shrink_to_hi() } else { lt_span };
let code = if elided { "'static " } else { "'static" }; let code = if elided { "'static " } else { "'static" };
ctx.emit_span_lint( lints::AssociatedConstElidedLifetime { span: lt_span, code, elided }
lint, .decorate_lint(diag);
span,
lints::AssociatedConstElidedLifetime { span: lt_span, code, elided },
);
} }
BuiltinLintDiag::RedundantImportVisibility { max_vis, span: vis_span, import_vis } => { BuiltinLintDiag::RedundantImportVisibility { max_vis, span: vis_span, import_vis } => {
ctx.emit_span_lint( lints::RedundantImportVisibility { span: vis_span, help: (), max_vis, import_vis }
lint, .decorate_lint(diag);
span,
lints::RedundantImportVisibility { span: vis_span, help: (), max_vis, import_vis },
);
} }
BuiltinLintDiag::UnknownDiagnosticAttribute { span: typo_span, typo_name } => { BuiltinLintDiag::UnknownDiagnosticAttribute { span: typo_span, typo_name } => {
let typo = typo_name.map(|typo_name| lints::UnknownDiagnosticAttributeTypoSugg { let typo = typo_name.map(|typo_name| lints::UnknownDiagnosticAttributeTypoSugg {
span: typo_span, span: typo_span,
typo_name, typo_name,
}); });
ctx.emit_span_lint(lint, span, lints::UnknownDiagnosticAttribute { typo }); lints::UnknownDiagnosticAttribute { typo }.decorate_lint(diag);
} }
BuiltinLintDiag::MacroUseDeprecated => { BuiltinLintDiag::MacroUseDeprecated => {
ctx.emit_span_lint(lint, span, lints::MacroUseDeprecated) lints::MacroUseDeprecated.decorate_lint(diag);
} }
BuiltinLintDiag::UnusedMacroUse => ctx.emit_span_lint(lint, span, lints::UnusedMacroUse), BuiltinLintDiag::UnusedMacroUse => lints::UnusedMacroUse.decorate_lint(diag),
BuiltinLintDiag::PrivateExternCrateReexport(ident) => { BuiltinLintDiag::PrivateExternCrateReexport(ident) => {
ctx.emit_span_lint(lint, span, lints::PrivateExternCrateReexport { ident }) lints::PrivateExternCrateReexport { ident }.decorate_lint(diag);
} }
BuiltinLintDiag::UnusedLabel => ctx.emit_span_lint(lint, span, lints::UnusedLabel), BuiltinLintDiag::UnusedLabel => lints::UnusedLabel.decorate_lint(diag),
BuiltinLintDiag::MacroIsPrivate(ident) => { BuiltinLintDiag::MacroIsPrivate(ident) => {
ctx.emit_span_lint(lint, span, lints::MacroIsPrivate { ident }) lints::MacroIsPrivate { ident }.decorate_lint(diag);
} }
BuiltinLintDiag::UnusedMacroDefinition(name) => { BuiltinLintDiag::UnusedMacroDefinition(name) => {
ctx.emit_span_lint(lint, span, lints::UnusedMacroDefinition { name }) lints::UnusedMacroDefinition { name }.decorate_lint(diag);
} }
BuiltinLintDiag::MacroRuleNeverUsed(n, name) => { BuiltinLintDiag::MacroRuleNeverUsed(n, name) => {
ctx.emit_span_lint(lint, span, lints::MacroRuleNeverUsed { n: n + 1, name }) lints::MacroRuleNeverUsed { n: n + 1, name }.decorate_lint(diag);
} }
BuiltinLintDiag::UnstableFeature(msg) => { BuiltinLintDiag::UnstableFeature(msg) => {
ctx.emit_span_lint(lint, span, lints::UnstableFeature { msg }) lints::UnstableFeature { msg }.decorate_lint(diag);
} }
BuiltinLintDiag::AvoidUsingIntelSyntax => { BuiltinLintDiag::AvoidUsingIntelSyntax => {
ctx.emit_span_lint(lint, span, lints::AvoidIntelSyntax) lints::AvoidIntelSyntax.decorate_lint(diag);
} }
BuiltinLintDiag::AvoidUsingAttSyntax => { BuiltinLintDiag::AvoidUsingAttSyntax => {
ctx.emit_span_lint(lint, span, lints::AvoidAttSyntax) lints::AvoidAttSyntax.decorate_lint(diag);
} }
BuiltinLintDiag::IncompleteInclude => { BuiltinLintDiag::IncompleteInclude => {
ctx.emit_span_lint(lint, span, lints::IncompleteInclude) lints::IncompleteInclude.decorate_lint(diag);
} }
BuiltinLintDiag::UnnameableTestItems => { BuiltinLintDiag::UnnameableTestItems => {
ctx.emit_span_lint(lint, span, lints::UnnameableTestItems) lints::UnnameableTestItems.decorate_lint(diag);
} }
BuiltinLintDiag::DuplicateMacroAttribute => { BuiltinLintDiag::DuplicateMacroAttribute => {
ctx.emit_span_lint(lint, span, lints::DuplicateMacroAttribute) lints::DuplicateMacroAttribute.decorate_lint(diag);
} }
BuiltinLintDiag::CfgAttrNoAttributes => { BuiltinLintDiag::CfgAttrNoAttributes => {
ctx.emit_span_lint(lint, span, lints::CfgAttrNoAttributes) lints::CfgAttrNoAttributes.decorate_lint(diag);
} }
BuiltinLintDiag::CrateTypeInCfgAttr => { BuiltinLintDiag::CrateTypeInCfgAttr => {
ctx.emit_span_lint(lint, span, lints::CrateTypeInCfgAttr) lints::CrateTypeInCfgAttr.decorate_lint(diag);
} }
BuiltinLintDiag::CrateNameInCfgAttr => { BuiltinLintDiag::CrateNameInCfgAttr => {
ctx.emit_span_lint(lint, span, lints::CrateNameInCfgAttr) lints::CrateNameInCfgAttr.decorate_lint(diag);
} }
BuiltinLintDiag::MissingFragmentSpecifier => { BuiltinLintDiag::MissingFragmentSpecifier => {
ctx.emit_span_lint(lint, span, lints::MissingFragmentSpecifier) lints::MissingFragmentSpecifier.decorate_lint(diag);
} }
BuiltinLintDiag::MetaVariableStillRepeating(name) => { BuiltinLintDiag::MetaVariableStillRepeating(name) => {
ctx.emit_span_lint(lint, span, lints::MetaVariableStillRepeating { name }) lints::MetaVariableStillRepeating { name }.decorate_lint(diag);
} }
BuiltinLintDiag::MetaVariableWrongOperator => { BuiltinLintDiag::MetaVariableWrongOperator => {
ctx.emit_span_lint(lint, span, lints::MetaVariableWrongOperator) lints::MetaVariableWrongOperator.decorate_lint(diag);
} }
BuiltinLintDiag::DuplicateMatcherBinding => { BuiltinLintDiag::DuplicateMatcherBinding => {
ctx.emit_span_lint(lint, span, lints::DuplicateMatcherBinding) lints::DuplicateMatcherBinding.decorate_lint(diag);
} }
BuiltinLintDiag::UnknownMacroVariable(name) => { BuiltinLintDiag::UnknownMacroVariable(name) => {
ctx.emit_span_lint(lint, span, lints::UnknownMacroVariable { name }) lints::UnknownMacroVariable { name }.decorate_lint(diag);
} }
BuiltinLintDiag::UnusedCrateDependency { extern_crate, local_crate } => ctx.emit_span_lint( BuiltinLintDiag::UnusedCrateDependency { extern_crate, local_crate } => {
lint, lints::UnusedCrateDependency { extern_crate, local_crate }.decorate_lint(diag)
span, }
lints::UnusedCrateDependency { extern_crate, local_crate }, BuiltinLintDiag::WasmCAbi => lints::WasmCAbi.decorate_lint(diag),
), BuiltinLintDiag::IllFormedAttributeInput { suggestions } => {
BuiltinLintDiag::WasmCAbi => ctx.emit_span_lint(lint, span, lints::WasmCAbi),
BuiltinLintDiag::IllFormedAttributeInput { suggestions } => ctx.emit_span_lint(
lint,
span,
lints::IllFormedAttributeInput { lints::IllFormedAttributeInput {
num_suggestions: suggestions.len(), num_suggestions: suggestions.len(),
suggestions: DiagArgValue::StrListSepByAnd( suggestions: DiagArgValue::StrListSepByAnd(
suggestions.into_iter().map(|s| format!("`{s}`").into()).collect(), suggestions.into_iter().map(|s| format!("`{s}`").into()).collect(),
), ),
}, }
), .decorate_lint(diag)
BuiltinLintDiag::InnerAttributeUnstable { is_macro } => ctx.emit_span_lint( }
lint, BuiltinLintDiag::InnerAttributeUnstable { is_macro } => if is_macro {
span, lints::InnerAttributeUnstable::InnerMacroAttribute
if is_macro { } else {
lints::InnerAttributeUnstable::InnerMacroAttribute lints::InnerAttributeUnstable::CustomInnerAttribute
} else { }
lints::InnerAttributeUnstable::CustomInnerAttribute .decorate_lint(diag),
},
),
} }
} }