@@ -297,7 +297,7 @@ pub(crate) fn check_tied_features(
297297/// Used to generate cfg variables and apply features
298298/// Must express features in the way Rust understands them
299299pub fn target_features ( sess : & Session , allow_unstable : bool ) -> Vec < Symbol > {
300- let mut features = vec ! [ ] ;
300+ let mut features: FxHashSet < Symbol > = Default :: default ( ) ;
301301
302302 // Add base features for the target.
303303 // We do *not* add the -Ctarget-features there, and instead duplicate the logic for that below.
@@ -306,7 +306,7 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
306306 // the target CPU, that is still expanded to target features (with all their implied features) by
307307 // LLVM.
308308 let target_machine = create_informational_target_machine ( sess, true ) ;
309- // Compute which of the known target features are enables in the 'base' target machine.
309+ // Compute which of the known target features are enabled in the 'base' target machine.
310310 features. extend (
311311 sess. target
312312 . known_target_features ( )
@@ -343,9 +343,12 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
343343 if enabled {
344344 features. extend ( sess. target . implied_target_features ( std:: iter:: once ( feature) ) ) ;
345345 } else {
346- features. retain ( |f| {
347- !sess. target . implied_target_features ( std:: iter:: once ( * f) ) . contains ( & feature)
348- } ) ;
346+ // We don't care about the order in `features` since the only thing we use it for is the
347+ // `features.contains` below.
348+ #[ allow( rustc:: potential_query_instability) ]
349+ for feature_to_remove in sess. target . implied_target_features ( std:: iter:: once ( feature) ) {
350+ features. remove ( & feature_to_remove) ;
351+ }
349352 }
350353 }
351354
0 commit comments