summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-02-25 20:26:12 +0100
committerRalf Jung <post@ralfj.de>2025-02-25 20:26:12 +0100
commitb6f22400002f7921feed13e35852e3041cf2b145 (patch)
tree13cebba2e2264ff4da757a4389d2a2f9803ec66b /compiler/rustc_codegen_ssa
parente0be1a02626abef2878cb7f4aaef7ae409477112 (diff)
downloadrust-b6f22400002f7921feed13e35852e3041cf2b145.tar.gz
rust-b6f22400002f7921feed13e35852e3041cf2b145.zip
rustdoc: disable forbidden #[target_feature] check
Diffstat (limited to 'compiler/rustc_codegen_ssa')
-rw-r--r--compiler/rustc_codegen_ssa/src/target_features.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs
index d8b9bdb55da..28c6932dd5b 100644
--- a/compiler/rustc_codegen_ssa/src/target_features.rs
+++ b/compiler/rustc_codegen_ssa/src/target_features.rs
@@ -87,7 +87,10 @@ pub(crate) fn from_target_feature_attr(
                     // But ensure the ABI does not forbid enabling this.
                     // Here we do assume that LLVM doesn't add even more implied features
                     // we don't know about, at least no features that would have ABI effects!
-                    if abi_feature_constraints.incompatible.contains(&name.as_str()) {
+                    // We skip this check in rustdoc, like we skip all target feature related checks.
+                    if !tcx.sess.opts.actually_rustdoc
+                        && abi_feature_constraints.incompatible.contains(&name.as_str())
+                    {
                         tcx.dcx().emit_err(errors::ForbiddenTargetFeatureAttr {
                             span: item.span(),
                             feature: name.as_str(),
@@ -142,8 +145,11 @@ pub(crate) fn provide(providers: &mut Providers) {
         rust_target_features: |tcx, cnum| {
             assert_eq!(cnum, LOCAL_CRATE);
             if tcx.sess.opts.actually_rustdoc {
-                // rustdoc needs to be able to document functions that use all the features, so
-                // whitelist them all
+                // HACK: rustdoc would like to pretend that we have all the target features, so we
+                // have to merge all the lists into one. The result has a "random" stability
+                // (depending on the order in which we consider features); all places that check
+                // target stability are expected to check `actually_rustdoc` and do nothing when
+                // that is set.
                 rustc_target::target_features::all_rust_features()
                     .map(|(a, b)| (a.to_string(), b))
                     .collect()