From 0c9d42cc56626bb383cbab3bb8529a8f1a117fed Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 15 Dec 2024 09:25:11 +0100 Subject: [PATCH] apply review feedback --- compiler/rustc_target/src/spec/mod.rs | 20 ++-------------- compiler/rustc_target/src/target_features.rs | 24 ++++++++++---------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 06d2099a446..f7cf12215f3 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2605,27 +2605,11 @@ impl TargetOptions { } pub(crate) fn has_feature(&self, search_feature: &str) -> bool { - self.features.split(',').any(|f| { - if let Some(f) = f.strip_prefix('+') - && f == search_feature - { - true - } else { - false - } - }) + self.features.split(',').any(|f| f.strip_prefix('+').is_some_and(|f| f == search_feature)) } pub(crate) fn has_neg_feature(&self, search_feature: &str) -> bool { - self.features.split(',').any(|f| { - if let Some(f) = f.strip_prefix('-') - && f == search_feature - { - true - } else { - false - } - }) + self.features.split(',').any(|f| f.strip_prefix('-').is_some_and(|f| f == search_feature)) } } diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index e1f7884610c..713b5dc70d7 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -105,10 +105,10 @@ impl Stability { /// - for `#[target_feature]`/`-Ctarget-feature`, check `allow_toggle()` /// - for `cfg(target_feature)`, check `in_cfg` pub fn requires_nightly(&self) -> Option { - match self { - &Stability::Unstable { nightly_feature, .. } => Some(nightly_feature), - &Stability::Stable { .. } => None, - &Stability::Forbidden { .. } => panic!("forbidden features should not reach this far"), + match *self { + Stability::Unstable { nightly_feature, .. } => Some(nightly_feature), + Stability::Stable { .. } => None, + Stability::Forbidden { .. } => panic!("forbidden features should not reach this far"), } } } @@ -120,21 +120,21 @@ impl StabilityUncomputed { enable: f(target, true), disable: f(target, false), }; - match self { - &Stable { allow_toggle } => Stable { allow_toggle: compute(allow_toggle) }, - &Unstable { nightly_feature, allow_toggle } => { + match *self { + Stable { allow_toggle } => Stable { allow_toggle: compute(allow_toggle) }, + Unstable { nightly_feature, allow_toggle } => { Unstable { nightly_feature, allow_toggle: compute(allow_toggle) } } - &Forbidden { reason } => Forbidden { reason }, + Forbidden { reason } => Forbidden { reason }, } } pub fn toggle_allowed(&self, target: &Target, enable: bool) -> Result<(), &'static str> { use Stability::*; - match self { - &Stable { allow_toggle } => allow_toggle(target, enable), - &Unstable { allow_toggle, .. } => allow_toggle(target, enable), - &Forbidden { reason } => Err(reason), + match *self { + Stable { allow_toggle } => allow_toggle(target, enable), + Unstable { allow_toggle, .. } => allow_toggle(target, enable), + Forbidden { reason } => Err(reason), } } }