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 {
|
pub(crate) fn has_feature(&self, search_feature: &str) -> bool {
|
||||||
self.features.split(',').any(|f| {
|
self.features.split(',').any(|f| f.strip_prefix('+').is_some_and(|f| f == search_feature))
|
||||||
if let Some(f) = f.strip_prefix('+')
|
|
||||||
&& f == search_feature
|
|
||||||
{
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn has_neg_feature(&self, search_feature: &str) -> bool {
|
pub(crate) fn has_neg_feature(&self, search_feature: &str) -> bool {
|
||||||
self.features.split(',').any(|f| {
|
self.features.split(',').any(|f| f.strip_prefix('-').is_some_and(|f| f == search_feature))
|
||||||
if let Some(f) = f.strip_prefix('-')
|
|
||||||
&& f == search_feature
|
|
||||||
{
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,10 +105,10 @@ impl<Toggleability> Stability<Toggleability> {
|
||||||
/// - for `#[target_feature]`/`-Ctarget-feature`, check `allow_toggle()`
|
/// - for `#[target_feature]`/`-Ctarget-feature`, check `allow_toggle()`
|
||||||
/// - for `cfg(target_feature)`, check `in_cfg`
|
/// - for `cfg(target_feature)`, check `in_cfg`
|
||||||
pub fn requires_nightly(&self) -> Option<Symbol> {
|
pub fn requires_nightly(&self) -> Option<Symbol> {
|
||||||
match self {
|
match *self {
|
||||||
&Stability::Unstable { nightly_feature, .. } => Some(nightly_feature),
|
Stability::Unstable { nightly_feature, .. } => Some(nightly_feature),
|
||||||
&Stability::Stable { .. } => None,
|
Stability::Stable { .. } => None,
|
||||||
&Stability::Forbidden { .. } => panic!("forbidden features should not reach this far"),
|
Stability::Forbidden { .. } => panic!("forbidden features should not reach this far"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,21 +120,21 @@ impl StabilityUncomputed {
|
||||||
enable: f(target, true),
|
enable: f(target, true),
|
||||||
disable: f(target, false),
|
disable: f(target, false),
|
||||||
};
|
};
|
||||||
match self {
|
match *self {
|
||||||
&Stable { allow_toggle } => Stable { allow_toggle: compute(allow_toggle) },
|
Stable { allow_toggle } => Stable { allow_toggle: compute(allow_toggle) },
|
||||||
&Unstable { nightly_feature, allow_toggle } => {
|
Unstable { nightly_feature, allow_toggle } => {
|
||||||
Unstable { nightly_feature, allow_toggle: compute(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> {
|
pub fn toggle_allowed(&self, target: &Target, enable: bool) -> Result<(), &'static str> {
|
||||||
use Stability::*;
|
use Stability::*;
|
||||||
match self {
|
match *self {
|
||||||
&Stable { allow_toggle } => allow_toggle(target, enable),
|
Stable { allow_toggle } => allow_toggle(target, enable),
|
||||||
&Unstable { allow_toggle, .. } => allow_toggle(target, enable),
|
Unstable { allow_toggle, .. } => allow_toggle(target, enable),
|
||||||
&Forbidden { reason } => Err(reason),
|
Forbidden { reason } => Err(reason),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue