refactor AttributeGate and rustc_attr! to emit notes during feature checking

This commit is contained in:
mejrs
2025-05-18 18:35:13 +02:00
parent 52882f6522
commit 959d6de1a9
26 changed files with 274 additions and 195 deletions

View File

@@ -818,25 +818,22 @@ impl EarlyLintPass for DeprecatedAttr {
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) {
for BuiltinAttribute { name, gate, .. } in &self.depr_attrs {
if attr.ident().map(|ident| ident.name) == Some(*name) {
if let &AttributeGate::Gated(
Stability::Deprecated(link, suggestion),
name,
reason,
_,
) = gate
if let &AttributeGate::Gated {
stability: Stability::Deprecated(link, suggestion),
message,
..
} = gate
{
let suggestion = match suggestion {
Some(msg) => {
BuiltinDeprecatedAttrLinkSuggestion::Msg { suggestion: attr.span, msg }
}
None => {
BuiltinDeprecatedAttrLinkSuggestion::Default { suggestion: attr.span }
Some(suggestion) => {
BuiltinDeprecatedAttrLinkSuggestion::Msg { span: attr.span, suggestion }
}
None => BuiltinDeprecatedAttrLinkSuggestion::Default { span: attr.span },
};
cx.emit_span_lint(
DEPRECATED,
attr.span,
BuiltinDeprecatedAttrLink { name, reason, link, suggestion },
BuiltinDeprecatedAttrLink { name: *name, message, link, suggestion },
);
}
return;