Skip to content

Commit f0748b2

Browse files
committed
Stabilize target_feature_11
1 parent 6f13ea0 commit f0748b2

33 files changed

+70
-151
lines changed

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
278278
{
279279
if tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc {
280280
// The `#[target_feature]` attribute is allowed on
281-
// WebAssembly targets on all functions, including safe
282-
// ones. Other targets require that `#[target_feature]` is
283-
// only applied to unsafe functions (pending the
284-
// `target_feature_11` feature) because on most targets
281+
// WebAssembly targets on all functions. Prior to stabilizing
282+
// the `target_feature_11` feature, `#[target_feature]` was
283+
// only permitted on safe functions because on most targets
285284
// execution of instructions that are not supported is
286285
// considered undefined behavior. For WebAssembly which is a
287286
// 100% safe target at execution time it's not possible to
@@ -295,17 +294,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
295294
// if a target is documenting some wasm-specific code then
296295
// it's not spuriously denied.
297296
//
298-
// This exception needs to be kept in sync with allowing
299-
// `#[target_feature]` on `main` and `start`.
300-
} else if !tcx.features().target_feature_11 {
301-
let mut err = feature_err(
302-
&tcx.sess.parse_sess,
303-
sym::target_feature_11,
304-
attr.span,
305-
"`#[target_feature(..)]` can only be applied to `unsafe` functions",
306-
);
307-
err.span_label(tcx.def_span(did), "not an `unsafe` function");
308-
err.emit();
297+
// Now that `#[target_feature]` is permitted on safe functions,
298+
// this exception must still exist for allowing the attribute on
299+
// `main`, `start`, and other functions that are not usually
300+
// allowed.
309301
} else {
310302
check_target_feature_trait_unsafe(tcx, did, attr.span);
311303
}
@@ -535,10 +527,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
535527
// its parent function, which effectively inherits the features anyway. Boxing this closure
536528
// would result in this closure being compiled without the inherited target features, but this
537529
// is probably a poor usage of `#[inline(always)]` and easily avoided by not using the attribute.
538-
if tcx.features().target_feature_11
539-
&& tcx.is_closure(did.to_def_id())
540-
&& codegen_fn_attrs.inline != InlineAttr::Always
541-
{
530+
if tcx.is_closure(did.to_def_id()) && codegen_fn_attrs.inline != InlineAttr::Always {
542531
let owner_id = tcx.parent(did.to_def_id());
543532
if tcx.def_kind(owner_id).has_codegen_attrs() {
544533
codegen_fn_attrs

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ declare_features! (
322322
(accepted, struct_variant, "1.0.0", None, None),
323323
/// Allows `#[target_feature(...)]`.
324324
(accepted, target_feature, "1.27.0", None, None),
325+
/// Allows the use of `#[target_feature]` on safe functions.
326+
(accepted, target_feature_11, "CURRENT_RUSTC_VERSION", Some(69098), None),
325327
/// Allows `fn main()` with return types which implements `Termination` (RFC 1937).
326328
(accepted, termination_trait, "1.26.0", Some(43301), None),
327329
/// Allows `#[test]` functions where the return type implements `Termination` (RFC 1937).

compiler/rustc_feature/src/active.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,6 @@ declare_features! (
558558
(active, strict_provenance, "1.61.0", Some(95228), None),
559559
/// Allows string patterns to dereference values to match them.
560560
(active, string_deref_patterns, "1.67.0", Some(87121), None),
561-
/// Allows the use of `#[target_feature]` on safe functions.
562-
(active, target_feature_11, "1.45.0", Some(69098), None),
563561
/// Allows using `#[thread_local]` on `static` items.
564562
(active, thread_local, "1.0.0", Some(29594), None),
565563
/// Allows defining `trait X = A + B;` alias items.

library/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@
246246
#![feature(simd_ffi)]
247247
#![feature(staged_api)]
248248
#![feature(stmt_expr_attributes)]
249-
#![feature(target_feature_11)]
250249
#![feature(trait_alias)]
251250
#![feature(transparent_unions)]
252251
#![feature(try_blocks)]

tests/assembly/closure-inherit-target-feature.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// make sure the feature is not enabled at compile-time
44
// compile-flags: -C opt-level=3 -C target-feature=-sse4.1 -C llvm-args=-x86-asm-syntax=intel
55

6-
#![feature(target_feature_11)]
76
#![crate_type = "rlib"]
87

98
use std::arch::x86_64::{__m128, _mm_blend_ps};

tests/codegen/target-feature-inline-closure.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// compile-flags: -Copt-level=3
33

44
#![crate_type = "lib"]
5-
#![feature(target_feature_11)]
65

76
#[cfg(target_arch = "x86_64")]
87
use std::arch::x86_64::*;

tests/mir-opt/inline/inline_compatibility.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#![crate_type = "lib"]
77
#![feature(no_sanitize)]
8-
#![feature(target_feature_11)]
98
#![feature(c_variadic)]
109

1110
// EMIT_MIR inline_compatibility.inlined_target_feature.Inline.diff

tests/ui/asm/x86_64/issue-89875.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// needs-asm-support
33
// only-x86_64
44

5-
#![feature(target_feature_11)]
6-
75
use std::arch::asm;
86

97
#[target_feature(enable = "avx")]

tests/ui/lang-items/start_lang_item_with_target_feature.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// only-x86_64
22
// check-fail
33

4-
#![feature(lang_items, no_core, target_feature_11)]
4+
#![feature(lang_items, no_core)]
55
#![no_core]
66

77
#[lang = "copy"]

tests/ui/panic-handler/panic-handler-with-target-feature.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// compile-flags:-C panic=abort
22
// only-x86_64
33

4-
#![feature(target_feature_11)]
54
#![no_std]
65
#![no_main]
76

0 commit comments

Comments
 (0)