about summary refs log tree commit diff
path: root/compiler/rustc_hir
diff options
context:
space:
mode:
authorLuca Versari <veluca@google.com>2025-08-18 15:09:45 +0200
committerLuca Versari <veluca@google.com>2025-08-22 01:26:26 +0200
commit291da71b2ae2e5d313739a7d6a8ffa634f408db5 (patch)
tree61a65575461bc4d16394c51ba93dff879b32a39b /compiler/rustc_hir
parent6ba0ce40941eee1ca02e9ba49c791ada5158747a (diff)
downloadrust-291da71b2ae2e5d313739a7d6a8ffa634f408db5.tar.gz
rust-291da71b2ae2e5d313739a7d6a8ffa634f408db5.zip
Add an experimental unsafe(force_target_feature) attribute.
This uses the feature gate for
https://github.com/rust-lang/rust/issues/143352, but is described in
https://github.com/rust-lang/rfcs/pull/3820 which is strongly tied to
the experiment.
Diffstat (limited to 'compiler/rustc_hir')
-rw-r--r--compiler/rustc_hir/src/attrs/data_structures.rs5
-rw-r--r--compiler/rustc_hir/src/attrs/encode_cross_crate.rs2
2 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs
index a17350f0392..2209b18df3f 100644
--- a/compiler/rustc_hir/src/attrs/data_structures.rs
+++ b/compiler/rustc_hir/src/attrs/data_structures.rs
@@ -524,8 +524,9 @@ pub enum AttributeKind {
     /// Represents `#[rustc_std_internal_symbol]`.
     StdInternalSymbol(Span),
 
-    /// Represents `#[target_feature(enable = "...")]`
-    TargetFeature(ThinVec<(Symbol, Span)>, Span),
+    /// Represents `#[target_feature(enable = "...")]` and
+    /// `#[unsafe(force_target_feature(enable = "...")]`.
+    TargetFeature { features: ThinVec<(Symbol, Span)>, attr_span: Span, was_forced: bool },
 
     /// Represents `#[track_caller]`
     TrackCaller(Span),
diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs
index defabdccc02..485ded3981f 100644
--- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs
+++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs
@@ -78,7 +78,7 @@ impl AttributeKind {
             SpecializationTrait(..) => No,
             Stability { .. } => Yes,
             StdInternalSymbol(..) => No,
-            TargetFeature(..) => No,
+            TargetFeature { .. } => No,
             TrackCaller(..) => Yes,
             TypeConst(..) => Yes,
             UnsafeSpecializationMarker(..) => No,