apply review feedback
This commit is contained in:
parent
1f8236d4c7
commit
0c9d42cc56
2 changed files with 14 additions and 30 deletions
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,10 +105,10 @@ impl<Toggleability> Stability<Toggleability> {
|
|||
/// - for `#[target_feature]`/`-Ctarget-feature`, check `allow_toggle()`
|
||||
/// - for `cfg(target_feature)`, check `in_cfg`
|
||||
pub fn requires_nightly(&self) -> Option<Symbol> {
|
||||
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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue