File tree 2 files changed +14
-6
lines changed
rustc_query_system/src/ich
2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ macro_rules! declare_features {
50
50
} ) ,+
51
51
] ;
52
52
53
+ const NUM_FEATURES : usize = UNSTABLE_FEATURES . len( ) ;
54
+
53
55
/// A set of features to be used by later passes.
54
56
#[ derive( Clone , Default , Debug ) ]
55
57
pub struct Features {
@@ -82,8 +84,14 @@ macro_rules! declare_features {
82
84
self . declared_features. insert( symbol) ;
83
85
}
84
86
85
- pub fn walk_feature_fields( & self , mut f: impl FnMut ( & str , bool ) ) {
86
- $( f( stringify!( $feature) , self . $feature) ; ) +
87
+ /// This is intended for hashing the set of active features.
88
+ ///
89
+ /// The expectation is that this produces much smaller code than other alternatives.
90
+ ///
91
+ /// Note that the total feature count is pretty small, so this is not a huge array.
92
+ #[ inline]
93
+ pub fn all_features( & self ) -> [ u8 ; NUM_FEATURES ] {
94
+ [ $( self . $feature as u8 ) ,+]
87
95
}
88
96
89
97
/// Is the given feature explicitly declared, i.e. named in a
Original file line number Diff line number Diff line change @@ -117,9 +117,9 @@ impl<'tcx> HashStable<StableHashingContext<'tcx>> for rustc_feature::Features {
117
117
self . declared_lang_features . hash_stable ( hcx, hasher) ;
118
118
self . declared_lib_features . hash_stable ( hcx, hasher) ;
119
119
120
- self . walk_feature_fields ( |feature_name , value| {
121
- feature_name . hash_stable ( hcx , hasher ) ;
122
- value . hash_stable ( hcx, hasher) ;
123
- } ) ;
120
+ self . all_features ( ) [ .. ] . hash_stable ( hcx , hasher ) ;
121
+ for feature in rustc_feature :: UNSTABLE_FEATURES . iter ( ) {
122
+ feature . feature . name . hash_stable ( hcx, hasher) ;
123
+ }
124
124
}
125
125
}
You can’t perform that action at this time.
0 commit comments