Skip to content

reject aarch64 target feature toggling that would change the float ABI #133417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
apply review feedback
  • Loading branch information
RalfJung committed Dec 15, 2024
commit 0c9d42cc56626bb383cbab3bb8529a8f1a117fed
20 changes: 2 additions & 18 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
24 changes: 12 additions & 12 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
}
}
Expand All @@ -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),
}
}
}
Expand Down
Loading