Remove span, unbox deprecation

This commit is contained in:
mejrs
2026-04-26 11:56:52 +02:00
parent eb9c3ee34d
commit 2ba2010170
7 changed files with 10 additions and 16 deletions
@@ -162,8 +162,7 @@ fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option<Attrib
}
Some(AttributeKind::Deprecated {
deprecation: Box::new(Deprecation { since, note, suggestion }),
span: cx.attr_span,
deprecation: Deprecation { since, note, suggestion },
})
}
}
+1 -1
View File
@@ -969,7 +969,7 @@ pub fn new(
stability,
deprecation: find_attr!(
attrs,
Deprecated { deprecation, .. } => **deprecation
Deprecated { deprecation, .. } => *deprecation
),
helper_attrs,
edition,
@@ -1013,8 +1013,7 @@ pub enum AttributeKind {
/// Represents [`#[deprecated]`](https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html#the-deprecated-attribute).
Deprecated {
deprecation: Box<Deprecation>,
span: Span,
deprecation: Deprecation,
},
/// Represents `#[diagnostic::do_not_recommend]`.
-1
View File
@@ -1376,7 +1376,6 @@ fn span(&self) -> Span {
Attribute::Unparsed(u) => u.span,
// FIXME: should not be needed anymore when all attrs are parsed
Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
Attribute::Parsed(AttributeKind::Deprecated { span, .. }) => *span,
Attribute::Parsed(AttributeKind::CfgTrace(cfgs)) => cfgs[0].1,
a => panic!("can't get the span of an arbitrary parsed attribute: {a:?}"),
}
+3 -2
View File
@@ -150,8 +150,9 @@ fn check_attributes(
Attribute::Parsed(AttributeKind::RustcAllowConstFnUnstable(_, first_span)) => {
self.check_rustc_allow_const_fn_unstable(hir_id, *first_span, span, target)
}
Attribute::Parsed(AttributeKind::Deprecated { span: attr_span, .. }) => {
self.check_deprecated(hir_id, *attr_span, target)
Attribute::Parsed(AttributeKind::Deprecated { .. }) => {
// FIXME move to attr parsing
self.check_deprecated(hir_id, rustc_span::DUMMY_SP, target)
}
Attribute::Parsed(AttributeKind::TargetFeature{ attr_span, ..}) => {
self.check_target_feature(hir_id, *attr_span, target, attrs)
+4 -4
View File
@@ -97,7 +97,7 @@ fn annotation_kind(tcx: TyCtxt<'_>, def_id: LocalDefId) -> AnnotationKind {
fn lookup_deprecation_entry(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<DeprecationEntry> {
let depr = find_attr!(tcx, def_id,
Deprecated { deprecation, .. } => **deprecation
Deprecated { deprecation, .. } => *deprecation
);
let Some(depr) = depr else {
@@ -324,6 +324,7 @@ fn check_compatible_stability(&self, def_id: LocalDefId) {
let depr = self.tcx.lookup_deprecation_entry(def_id);
let stab = self.tcx.lookup_stability(def_id);
let const_stab = self.tcx.lookup_const_stability(def_id);
let attrs = self.tcx.hir_attrs(self.tcx.local_def_id_to_hir_id(def_id));
macro_rules! find_attr_span {
($name:ident) => {{
@@ -334,9 +335,9 @@ macro_rules! find_attr_span {
if stab.is_none()
&& depr.map_or(false, |d| d.attr.is_since_rustc_version())
&& let Some(span) = find_attr_span!(Deprecated)
&& find_attr!(attrs, Deprecated { .. })
{
self.tcx.dcx().emit_err(errors::DeprecatedAttribute { span });
self.tcx.dcx().emit_err(errors::DeprecatedAttribute { span: rustc_span::DUMMY_SP });
}
if let Some(stab) = stab {
@@ -379,7 +380,6 @@ macro_rules! find_attr_span {
}
}
}
let attrs = self.tcx.hir_attrs(self.tcx.local_def_id_to_hir_id(def_id));
// If the current node is a function with const stability attributes (directly given or
// implied), check if the function/method is const or the parent impl block is const.
@@ -153,10 +153,6 @@ LL | #[deprecated(since = "invalid", note = "text")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0549]: deprecated attribute must be paired with either stable or unstable attribute
--> $DIR/stability-attribute-sanity.rs:71:1
|
LL | #[deprecated(since = "5.5.5", note = "text")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0711]: feature `a` is declared stable since 1.0.0, but was previously declared stable since 4.4.4
--> $DIR/stability-attribute-sanity.rs:67:1