@@ -54,61 +54,48 @@ macro_rules! declare_features {
5454 #[ derive( Clone , Default , Debug ) ]
5555 pub struct Features {
5656 /// `#![feature]` attrs for language features, for error reporting.
57- /// "declared" here means that the feature is actually enabled in the current crate.
58- pub declared_lang_features: Vec <( Symbol , Span , Option <Symbol >) >,
57+ pub enabled_lang_features: Vec <( Symbol , Span , Option <Symbol >) >,
5958 /// `#![feature]` attrs for non-language (library) features.
60- /// "declared" here means that the feature is actually enabled in the current crate.
61- pub declared_lib_features : Vec < ( Symbol , Span ) > ,
62- /// `declared_lang_features` + `declared_lib_features`.
63- pub declared_features : FxHashSet < Symbol > ,
64- /// Active state of individual features (unstable only) .
59+ pub enabled_lib_features : Vec < ( Symbol , Span ) > ,
60+ /// `enabled_lang_features` + `enabled_lib_features`.
61+ pub enabled_features : FxHashSet < Symbol > ,
62+ /// State of individual features (unstable lang features only).
63+ /// This is `true` if and only if the corresponding feature is listed in `enabled_lang_features` .
6564 $(
6665 $( #[ doc = $doc] ) *
6766 pub $feature: bool
6867 ) ,+
6968 }
7069
7170 impl Features {
72- pub fn set_declared_lang_feature (
71+ pub fn set_enabled_lang_feature (
7372 & mut self ,
7473 symbol: Symbol ,
7574 span: Span ,
7675 since: Option <Symbol >
7776 ) {
78- self . declared_lang_features . push( ( symbol, span, since) ) ;
79- self . declared_features . insert( symbol) ;
77+ self . enabled_lang_features . push( ( symbol, span, since) ) ;
78+ self . enabled_features . insert( symbol) ;
8079 }
8180
82- pub fn set_declared_lib_feature ( & mut self , symbol: Symbol , span: Span ) {
83- self . declared_lib_features . push( ( symbol, span) ) ;
84- self . declared_features . insert( symbol) ;
81+ pub fn set_enabled_lib_feature ( & mut self , symbol: Symbol , span: Span ) {
82+ self . enabled_lib_features . push( ( symbol, span) ) ;
83+ self . enabled_features . insert( symbol) ;
8584 }
8685
87- /// This is intended for hashing the set of active features.
86+ /// This is intended for hashing the set of enabled language features.
8887 ///
8988 /// The expectation is that this produces much smaller code than other alternatives.
9089 ///
9190 /// Note that the total feature count is pretty small, so this is not a huge array.
9291 #[ inline]
93- pub fn all_features ( & self ) -> [ u8 ; NUM_FEATURES ] {
92+ pub fn all_lang_features ( & self ) -> [ u8 ; NUM_FEATURES ] {
9493 [ $( self . $feature as u8 ) ,+]
9594 }
9695
97- /// Is the given feature explicitly declared, i.e. named in a
98- /// `#![feature(...)]` within the code?
99- pub fn declared( & self , feature: Symbol ) -> bool {
100- self . declared_features. contains( & feature)
101- }
102-
103- /// Is the given feature active (enabled by the user)?
104- ///
105- /// Panics if the symbol doesn't correspond to a declared feature.
106- pub fn active( & self , feature: Symbol ) -> bool {
107- match feature {
108- $( sym:: $feature => self . $feature, ) *
109-
110- _ => panic!( "`{}` was not listed in `declare_features`" , feature) ,
111- }
96+ /// Is the given feature enabled (via `#[feature(...)]`)?
97+ pub fn enabled( & self , feature: Symbol ) -> bool {
98+ self . enabled_features. contains( & feature)
11299 }
113100
114101 /// Some features are known to be incomplete and using them is likely to have
@@ -119,8 +106,11 @@ macro_rules! declare_features {
119106 $(
120107 sym:: $feature => status_to_enum!( $status) == FeatureStatus :: Incomplete ,
121108 ) *
122- // Accepted/removed features aren't in this file but are never incomplete.
123- _ if self . declared_features. contains( & feature) => false ,
109+ _ if self . enabled_features. contains( & feature) => {
110+ // Accepted/removed features and library features aren't in this file but
111+ // are never incomplete.
112+ false
113+ }
124114 _ => panic!( "`{}` was not listed in `declare_features`" , feature) ,
125115 }
126116 }
@@ -132,7 +122,7 @@ macro_rules! declare_features {
132122 $(
133123 sym:: $feature => status_to_enum!( $status) == FeatureStatus :: Internal ,
134124 ) *
135- _ if self . declared_features . contains( & feature) => {
125+ _ if self . enabled_features . contains( & feature) => {
136126 // This could be accepted/removed, or a libs feature.
137127 // Accepted/removed features aren't in this file but are never internal
138128 // (a removed feature might have been internal, but that's now irrelevant).
0 commit comments