@@ -54,61 +54,48 @@ macro_rules! declare_features {
54
54
#[ derive( Clone , Default , Debug ) ]
55
55
pub struct Features {
56
56
/// `#![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 active_lang_features: Vec <( Symbol , Span , Option <Symbol >) >,
59
58
/// `#![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 active_lib_features : Vec < ( Symbol , Span ) > ,
60
+ /// `active_lang_features` + `active_lib_features`.
61
+ pub active_features : FxHashSet < Symbol > ,
62
+ /// Active state of individual features (unstable lang features only).
63
+ /// This is `true` if and only if the corresponding feature is listed in `active_lang_features` .
65
64
$(
66
65
$( #[ doc = $doc] ) *
67
66
pub $feature: bool
68
67
) ,+
69
68
}
70
69
71
70
impl Features {
72
- pub fn set_declared_lang_feature (
71
+ pub fn set_active_lang_feature (
73
72
& mut self ,
74
73
symbol: Symbol ,
75
74
span: Span ,
76
75
since: Option <Symbol >
77
76
) {
78
- self . declared_lang_features . push( ( symbol, span, since) ) ;
79
- self . declared_features . insert( symbol) ;
77
+ self . active_lang_features . push( ( symbol, span, since) ) ;
78
+ self . active_features . insert( symbol) ;
80
79
}
81
80
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_active_lib_feature ( & mut self , symbol: Symbol , span: Span ) {
82
+ self . active_lib_features . push( ( symbol, span) ) ;
83
+ self . active_features . insert( symbol) ;
85
84
}
86
85
87
- /// This is intended for hashing the set of active features.
86
+ /// This is intended for hashing the set of active language features.
88
87
///
89
88
/// The expectation is that this produces much smaller code than other alternatives.
90
89
///
91
90
/// Note that the total feature count is pretty small, so this is not a huge array.
92
91
#[ inline]
93
- pub fn all_features ( & self ) -> [ u8 ; NUM_FEATURES ] {
92
+ pub fn all_lang_features ( & self ) -> [ u8 ; NUM_FEATURES ] {
94
93
[ $( self . $feature as u8 ) ,+]
95
94
}
96
95
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
96
/// Is the given feature active (enabled by the user)?
104
- ///
105
- /// Panics if the symbol doesn't correspond to a declared feature.
106
97
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
- }
98
+ self . active_features. contains( & feature)
112
99
}
113
100
114
101
/// Some features are known to be incomplete and using them is likely to have
@@ -119,8 +106,11 @@ macro_rules! declare_features {
119
106
$(
120
107
sym:: $feature => status_to_enum!( $status) == FeatureStatus :: Incomplete ,
121
108
) *
122
- // Accepted/removed features aren't in this file but are never incomplete.
123
- _ if self . declared_features. contains( & feature) => false ,
109
+ _ if self . active_features. contains( & feature) => {
110
+ // Accepted/removed features and library features aren't in this file but
111
+ // are never incomplete.
112
+ false
113
+ }
124
114
_ => panic!( "`{}` was not listed in `declare_features`" , feature) ,
125
115
}
126
116
}
@@ -132,7 +122,7 @@ macro_rules! declare_features {
132
122
$(
133
123
sym:: $feature => status_to_enum!( $status) == FeatureStatus :: Internal ,
134
124
) *
135
- _ if self . declared_features . contains( & feature) => {
125
+ _ if self . active_features . contains( & feature) => {
136
126
// This could be accepted/removed, or a libs feature.
137
127
// Accepted/removed features aren't in this file but are never internal
138
128
// (a removed feature might have been internal, but that's now irrelevant).
0 commit comments