diff options
| author | David Tolnay <dtolnay@gmail.com> | 2022-03-26 19:20:36 -0700 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2022-03-31 12:34:46 -0700 |
| commit | 5d30180634080dd761db77afc748dfd58e192a1d (patch) | |
| tree | 248813ffedf69d27e58faa16416f00fe0a1a6e5b /compiler/rustc_passes | |
| parent | bd1a8692f6260fd59dba1e0fa187092a1c354b2e (diff) | |
| download | rust-5d30180634080dd761db77afc748dfd58e192a1d.tar.gz rust-5d30180634080dd761db77afc748dfd58e192a1d.zip | |
Handle rustc_const_stable attribute in library feature collector
Diffstat (limited to 'compiler/rustc_passes')
| -rw-r--r-- | compiler/rustc_passes/src/lib_features.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_passes/src/lib_features.rs b/compiler/rustc_passes/src/lib_features.rs index 00445690f8f..c414d7c031c 100644 --- a/compiler/rustc_passes/src/lib_features.rs +++ b/compiler/rustc_passes/src/lib_features.rs @@ -29,10 +29,11 @@ impl<'tcx> LibFeatureCollector<'tcx> { } fn extract(&self, attr: &Attribute) -> Option<(Symbol, Option<Symbol>, Span)> { - let stab_attrs = [sym::stable, sym::unstable, sym::rustc_const_unstable]; + let stab_attrs = + [sym::stable, sym::unstable, sym::rustc_const_stable, sym::rustc_const_unstable]; - // Find a stability attribute (i.e., `#[stable (..)]`, `#[unstable (..)]`, - // `#[rustc_const_unstable (..)]`). + // Find a stability attribute: one of #[stable(…)], #[unstable(…)], + // #[rustc_const_stable(…)], or #[rustc_const_unstable(…)]. if let Some(stab_attr) = stab_attrs.iter().find(|stab_attr| attr.has_name(**stab_attr)) { let meta_kind = attr.meta_kind(); if let Some(MetaItemKind::List(ref metas)) = meta_kind { @@ -52,7 +53,9 @@ impl<'tcx> LibFeatureCollector<'tcx> { // This additional check for stability is to make sure we // don't emit additional, irrelevant errors for malformed // attributes. - if *stab_attr != sym::stable || since.is_some() { + let is_unstable = + matches!(*stab_attr, sym::unstable | sym::rustc_const_unstable); + if since.is_some() || is_unstable { return Some((feature, since, attr.span)); } } |
