1
Fork 0

Disallow enabling features without their implied features

This commit is contained in:
Caleb Zulawski 2024-08-06 00:35:32 -04:00
parent 0b98a0c727
commit 8818c95528
5 changed files with 11 additions and 23 deletions

View file

@ -277,7 +277,7 @@ pub fn check_tied_features(
/// Used to generate cfg variables and apply features
/// Must express features in the way Rust understands them
pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
let mut features = FxHashSet::default();
let mut features = vec![];
// Add base features for the target
let target_machine = create_informational_target_machine(sess, true);
@ -313,7 +313,9 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
if enabled {
features.extend(sess.target.implied_target_features(std::iter::once(feature)));
} else {
features.remove(&feature);
features.retain(|f| {
!sess.target.implied_target_features(std::iter::once(*f)).contains(&feature)
});
}
}