Collect features from #[rustc_default_body_unstable]

This commit is contained in:
Maybe Waffle 2022-04-27 19:00:17 +04:00
parent 177af47104
commit 9015a5110f

View File

@ -29,11 +29,16 @@ impl<'tcx> LibFeatureCollector<'tcx> {
} }
fn extract(&self, attr: &Attribute) -> Option<(Symbol, Option<Symbol>, Span)> { fn extract(&self, attr: &Attribute) -> Option<(Symbol, Option<Symbol>, Span)> {
let stab_attrs = let stab_attrs = [
[sym::stable, sym::unstable, sym::rustc_const_stable, sym::rustc_const_unstable]; sym::stable,
sym::unstable,
sym::rustc_const_stable,
sym::rustc_const_unstable,
sym::rustc_default_body_unstable,
];
// Find a stability attribute: one of #[stable(…)], #[unstable(…)], // Find a stability attribute: one of #[stable(…)], #[unstable(…)],
// #[rustc_const_stable(…)], or #[rustc_const_unstable(…)]. // #[rustc_const_stable(…)], #[rustc_const_unstable(…)] or #[rustc_default_body_unstable].
if let Some(stab_attr) = stab_attrs.iter().find(|stab_attr| attr.has_name(**stab_attr)) { if let Some(stab_attr) = stab_attrs.iter().find(|stab_attr| attr.has_name(**stab_attr)) {
let meta_kind = attr.meta_kind(); let meta_kind = attr.meta_kind();
if let Some(MetaItemKind::List(ref metas)) = meta_kind { if let Some(MetaItemKind::List(ref metas)) = meta_kind {
@ -53,8 +58,12 @@ impl<'tcx> LibFeatureCollector<'tcx> {
// This additional check for stability is to make sure we // This additional check for stability is to make sure we
// don't emit additional, irrelevant errors for malformed // don't emit additional, irrelevant errors for malformed
// attributes. // attributes.
let is_unstable = let is_unstable = matches!(
matches!(*stab_attr, sym::unstable | sym::rustc_const_unstable); *stab_attr,
sym::unstable
| sym::rustc_const_unstable
| sym::rustc_default_body_unstable
);
if since.is_some() || is_unstable { if since.is_some() || is_unstable {
return Some((feature, since, attr.span)); return Some((feature, since, attr.span));
} }