about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorLéo Lanteri Thauvin <leseulartichaut@gmail.com>2022-07-23 14:32:52 +0200
committerLéo Lanteri Thauvin <leseulartichaut@gmail.com>2023-02-01 08:53:02 +0100
commitb379d216eefaba083a0627b1724d73f99d4bdf5c (patch)
tree740541ec30d79ee76eec12d8ce696ecb99aec7cc /compiler
parent0d32c8f2ce10710b6560dcb75f32f79c378410d0 (diff)
downloadrust-b379d216eefaba083a0627b1724d73f99d4bdf5c.tar.gz
rust-b379d216eefaba083a0627b1724d73f99d4bdf5c.zip
Stabilize `#![feature(target_feature_11)]`
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_codegen_ssa/src/codegen_attrs.rs47
-rw-r--r--compiler/rustc_feature/src/accepted.rs2
-rw-r--r--compiler/rustc_feature/src/active.rs2
3 files changed, 20 insertions, 31 deletions
diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
index 87b819ebc98..e80313b23e9 100644
--- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
+++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs
@@ -268,34 +268,23 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
             if !tcx.is_closure(did.to_def_id())
                 && tcx.fn_sig(did).skip_binder().unsafety() == hir::Unsafety::Normal
             {
-                if tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc {
-                    // The `#[target_feature]` attribute is allowed on
-                    // WebAssembly targets on all functions, including safe
-                    // ones. Other targets require that `#[target_feature]` is
-                    // only applied to unsafe functions (pending the
-                    // `target_feature_11` feature) because on most targets
-                    // execution of instructions that are not supported is
-                    // considered undefined behavior. For WebAssembly which is a
-                    // 100% safe target at execution time it's not possible to
-                    // execute undefined instructions, and even if a future
-                    // feature was added in some form for this it would be a
-                    // deterministic trap. There is no undefined behavior when
-                    // executing WebAssembly so `#[target_feature]` is allowed
-                    // on safe functions (but again, only for WebAssembly)
-                    //
-                    // Note that this is also allowed if `actually_rustdoc` so
-                    // if a target is documenting some wasm-specific code then
-                    // it's not spuriously denied.
-                } else if !tcx.features().target_feature_11 {
-                    let mut err = feature_err(
-                        &tcx.sess.parse_sess,
-                        sym::target_feature_11,
-                        attr.span,
-                        "`#[target_feature(..)]` can only be applied to `unsafe` functions",
-                    );
-                    err.span_label(tcx.def_span(did), "not an `unsafe` function");
-                    err.emit();
-                } else {
+                // The `#[target_feature]` attribute is allowed on
+                // WebAssembly targets on all functions, including safe
+                // ones. Other targets have conditions on the usage of
+                // `#[target_feature]` because on most targets
+                // execution of instructions that are not supported is
+                // considered undefined behavior. For WebAssembly which is a
+                // 100% safe target at execution time it's not possible to
+                // execute undefined instructions, and even if a future
+                // feature was added in some form for this it would be a
+                // deterministic trap. There is no undefined behavior when
+                // executing WebAssembly so `#[target_feature]` is allowed
+                // on safe functions (but again, only for WebAssembly)
+                //
+                // Note that this is also allowed if `actually_rustdoc` so
+                // if a target is documenting some wasm-specific code then
+                // it's not spuriously denied.
+                if !(tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc) {
                     check_target_feature_trait_unsafe(tcx, did, attr.span);
                 }
             }
@@ -533,7 +522,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
     });
 
     // #73631: closures inherit `#[target_feature]` annotations
-    if tcx.features().target_feature_11 && tcx.is_closure(did.to_def_id()) {
+    if tcx.is_closure(did.to_def_id()) {
         let owner_id = tcx.parent(did.to_def_id());
         if tcx.def_kind(owner_id).has_codegen_attrs() {
             codegen_fn_attrs
diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs
index e064e87a59a..2d80c15589d 100644
--- a/compiler/rustc_feature/src/accepted.rs
+++ b/compiler/rustc_feature/src/accepted.rs
@@ -312,6 +312,8 @@ declare_features! (
     (accepted, struct_variant, "1.0.0", None, None),
     /// Allows `#[target_feature(...)]`.
     (accepted, target_feature, "1.27.0", None, None),
+    /// Allows the use of `#[target_feature]` on safe functions.
+    (accepted, target_feature_11, "CURRENT_RUSTC_VERSION", Some(69098), None),
     /// Allows `fn main()` with return types which implements `Termination` (RFC 1937).
     (accepted, termination_trait, "1.26.0", Some(43301), None),
     /// Allows `#[test]` functions where the return type implements `Termination` (RFC 1937).
diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs
index 323f5a368fc..7c8cc999106 100644
--- a/compiler/rustc_feature/src/active.rs
+++ b/compiler/rustc_feature/src/active.rs
@@ -509,8 +509,6 @@ declare_features! (
     (active, strict_provenance, "1.61.0", Some(95228), None),
     /// Allows string patterns to dereference values to match them.
     (active, string_deref_patterns, "1.67.0", Some(87121), None),
-    /// Allows the use of `#[target_feature]` on safe functions.
-    (active, target_feature_11, "1.45.0", Some(69098), None),
     /// Allows using `#[thread_local]` on `static` items.
     (active, thread_local, "1.0.0", Some(29594), None),
     /// Allows defining `trait X = A + B;` alias items.