diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-01-16 16:25:47 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-03-03 18:08:30 +0100 |
| commit | fbcf7d415b806e494a582c108f609abd43b3ef6b (patch) | |
| tree | 99bf41d7250a462dded6ad8af7e2f927cda607e2 /compiler/rustc_feature | |
| parent | 45660949132222ba7ec0905649b2affd68e0e13c (diff) | |
| download | rust-fbcf7d415b806e494a582c108f609abd43b3ef6b.tar.gz rust-fbcf7d415b806e494a582c108f609abd43b3ef6b.zip | |
Move the set of features to the `features` query.
Diffstat (limited to 'compiler/rustc_feature')
| -rw-r--r-- | compiler/rustc_feature/src/active.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 1d9d16e85cb..1f7dc769512 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -2,6 +2,7 @@ use super::{to_nonzero, Feature, State}; +use rustc_data_structures::fx::FxHashSet; use rustc_span::edition::Edition; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; @@ -47,6 +48,8 @@ macro_rules! declare_features { pub declared_lang_features: Vec<(Symbol, Span, Option<Symbol>)>, /// `#![feature]` attrs for non-language (library) features. pub declared_lib_features: Vec<(Symbol, Span)>, + /// Features enabled for this crate. + pub active_features: FxHashSet<Symbol>, $( $(#[doc = $doc])* pub $feature: bool @@ -58,6 +61,11 @@ macro_rules! declare_features { $(f(stringify!($feature), self.$feature);)+ } + /// Is the given feature active? + pub fn active(&self, feature: Symbol) -> bool { + self.active_features.contains(&feature) + } + /// Is the given feature enabled? /// /// Panics if the symbol doesn't correspond to a declared feature. |
