about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-01-05 10:34:33 +0100
committerRalf Jung <post@ralfj.de>2025-01-05 10:46:30 +0100
commit2e64b5352be9ec8b2a7b956c2be108394b85f4b0 (patch)
tree1b266e63d96229182c200d2785455ca04a8e5092 /compiler/rustc_codegen_gcc/src
parent43ede97ebf7d874c9076723840c945b051b10ee2 (diff)
downloadrust-2e64b5352be9ec8b2a7b956c2be108394b85f4b0.tar.gz
rust-2e64b5352be9ec8b2a7b956c2be108394b85f4b0.zip
add dedicated type for ABI target feature constraints
Diffstat (limited to 'compiler/rustc_codegen_gcc/src')
-rw-r--r--compiler/rustc_codegen_gcc/src/gcc_util.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_gcc/src/gcc_util.rs b/compiler/rustc_codegen_gcc/src/gcc_util.rs
index e9dfb4e4cf4..1994a2a3c53 100644
--- a/compiler/rustc_codegen_gcc/src/gcc_util.rs
+++ b/compiler/rustc_codegen_gcc/src/gcc_util.rs
@@ -47,9 +47,9 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
 
     // Ensure that all ABI-required features are enabled, and the ABI-forbidden ones
     // are disabled.
-    let (abi_enable, abi_disable) = sess.target.abi_required_features();
-    let abi_enable_set = FxHashSet::from_iter(abi_enable.iter().copied());
-    let abi_disable_set = FxHashSet::from_iter(abi_disable.iter().copied());
+    let abi_feature_constraints = sess.target.abi_required_features();
+    let abi_incompatible_set =
+        FxHashSet::from_iter(abi_feature_constraints.incompatible.iter().copied());
 
     // Compute implied features
     let mut all_rust_features = vec![];
@@ -72,7 +72,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
             }
         }
     }
-    // Remove features that are meant for rustc, not LLVM.
+    // Remove features that are meant for rustc, not codegen.
     all_rust_features.retain(|(_, feature)| {
         // Retain if it is not a rustc feature
         !RUSTC_SPECIFIC_FEATURES.contains(feature)
@@ -121,7 +121,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
 
             // Ensure that the features we enable/disable are compatible with the ABI.
             if enable {
-                if abi_disable_set.contains(feature) {
+                if abi_incompatible_set.contains(feature) {
                     sess.dcx().emit_warn(ForbiddenCTargetFeature {
                         feature,
                         enabled: "enabled",
@@ -131,8 +131,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
             } else {
                 // FIXME: we have to request implied features here since
                 // negative features do not handle implied features above.
-                #[allow(rustc::potential_query_instability)] // order does not matter
-                for &required in abi_enable_set.iter() {
+                for &required in abi_feature_constraints.required.iter() {
                     let implied = sess.target.implied_target_features(std::iter::once(required));
                     if implied.contains(feature) {
                         sess.dcx().emit_warn(ForbiddenCTargetFeature {
@@ -158,7 +157,11 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
     // still override it... that's unsound, but more compatible with past behavior.
     all_rust_features.splice(
         0..0,
-        abi_enable.iter().map(|&f| (true, f)).chain(abi_disable.iter().map(|&f| (false, f))),
+        abi_feature_constraints
+            .required
+            .iter()
+            .map(|&f| (true, f))
+            .chain(abi_feature_constraints.incompatible.iter().map(|&f| (false, f))),
     );
 
     // Translate this into GCC features.