Skip to content

Commit 0e29433

Browse files
committed
clean up target feature system; most of the toggleability is now handled by the ABI target feature check
1 parent 83ecc3e commit 0e29433

File tree

4 files changed

+349
-438
lines changed

4 files changed

+349
-438
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ pub(crate) fn global_llvm_features(
728728
sess.dcx().emit_warn(unknown_feature);
729729
}
730730
Some((_, stability, _)) => {
731-
if let Err(reason) = stability.toggle_allowed(&sess.target, enable) {
731+
if let Err(reason) = stability.toggle_allowed() {
732732
sess.dcx().emit_warn(ForbiddenCTargetFeature {
733733
feature,
734734
enabled: if enable { "enabled" } else { "disabled" },

compiler/rustc_codegen_ssa/src/target_features.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::errors;
1919
pub(crate) fn from_target_feature_attr(
2020
tcx: TyCtxt<'_>,
2121
attr: &hir::Attribute,
22-
rust_target_features: &UnordMap<String, target_features::StabilityComputed>,
22+
rust_target_features: &UnordMap<String, target_features::Stability>,
2323
target_features: &mut Vec<TargetFeature>,
2424
) {
2525
let Some(list) = attr.meta_item_list() else { return };
@@ -64,7 +64,7 @@ pub(crate) fn from_target_feature_attr(
6464

6565
// Only allow target features whose feature gates have been enabled
6666
// and which are permitted to be toggled.
67-
if let Err(reason) = stability.toggle_allowed(/*enable*/ true) {
67+
if let Err(reason) = stability.toggle_allowed() {
6868
tcx.dcx().emit_err(errors::ForbiddenTargetFeatureAttr {
6969
span: item.span(),
7070
feature,
@@ -141,19 +141,18 @@ pub(crate) fn provide(providers: &mut Providers) {
141141
*providers = Providers {
142142
rust_target_features: |tcx, cnum| {
143143
assert_eq!(cnum, LOCAL_CRATE);
144-
let target = &tcx.sess.target;
145144
if tcx.sess.opts.actually_rustdoc {
146145
// rustdoc needs to be able to document functions that use all the features, so
147146
// whitelist them all
148147
rustc_target::target_features::all_rust_features()
149-
.map(|(a, b)| (a.to_string(), b.compute_toggleability(target)))
148+
.map(|(a, b)| (a.to_string(), b))
150149
.collect()
151150
} else {
152151
tcx.sess
153152
.target
154153
.rust_target_features()
155154
.iter()
156-
.map(|(a, b, _)| (a.to_string(), b.compute_toggleability(target)))
155+
.map(|(a, b, _)| (a.to_string(), *b))
157156
.collect()
158157
}
159158
},

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,7 @@ rustc_queries! {
22322232
}
22332233

22342234
/// Returns the Rust target features for the current target. These are not always the same as LLVM target features!
2235-
query rust_target_features(_: CrateNum) -> &'tcx UnordMap<String, rustc_target::target_features::StabilityComputed> {
2235+
query rust_target_features(_: CrateNum) -> &'tcx UnordMap<String, rustc_target::target_features::Stability> {
22362236
arena_cache
22372237
eval_always
22382238
desc { "looking up Rust target features" }

0 commit comments

Comments
 (0)