Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 668ab73

Browse files
calebzulawskiveluca93
authored andcommittedDec 13, 2024·
Stabilize target_feature_11
1 parent f4f0faf commit 668ab73

38 files changed

+260
-159
lines changed
 

‎compiler/rustc_codegen_ssa/src/codegen_attrs.rs

+8-19
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
255255
{
256256
if tcx.sess.target.is_like_wasm || tcx.sess.opts.actually_rustdoc {
257257
// The `#[target_feature]` attribute is allowed on
258-
// WebAssembly targets on all functions, including safe
259-
// ones. Other targets require that `#[target_feature]` is
260-
// only applied to unsafe functions (pending the
261-
// `target_feature_11` feature) because on most targets
258+
// WebAssembly targets on all functions. Prior to stabilizing
259+
// the `target_feature_11` feature, `#[target_feature]` was
260+
// only permitted on safe functions because on most targets
262261
// execution of instructions that are not supported is
263262
// considered undefined behavior. For WebAssembly which is a
264263
// 100% safe target at execution time it's not possible to
@@ -272,17 +271,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
272271
// if a target is documenting some wasm-specific code then
273272
// it's not spuriously denied.
274273
//
275-
// This exception needs to be kept in sync with allowing
276-
// `#[target_feature]` on `main` and `start`.
277-
} else if !tcx.features().target_feature_11() {
278-
feature_err(
279-
&tcx.sess,
280-
sym::target_feature_11,
281-
attr.span,
282-
"`#[target_feature(..)]` can only be applied to `unsafe` functions",
283-
)
284-
.with_span_label(tcx.def_span(did), "not an `unsafe` function")
285-
.emit();
274+
// Now that `#[target_feature]` is permitted on safe functions,
275+
// this exception must still exist for allowing the attribute on
276+
// `main`, `start`, and other functions that are not usually
277+
// allowed.
286278
} else {
287279
check_target_feature_trait_unsafe(tcx, did, attr.span);
288280
}
@@ -599,10 +591,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
599591
// its parent function, which effectively inherits the features anyway. Boxing this closure
600592
// would result in this closure being compiled without the inherited target features, but this
601593
// is probably a poor usage of `#[inline(always)]` and easily avoided by not using the attribute.
602-
if tcx.features().target_feature_11()
603-
&& tcx.is_closure_like(did.to_def_id())
604-
&& codegen_fn_attrs.inline != InlineAttr::Always
605-
{
594+
if tcx.is_closure_like(did.to_def_id()) && codegen_fn_attrs.inline != InlineAttr::Always {
606595
let owner_id = tcx.parent(did.to_def_id());
607596
if tcx.def_kind(owner_id).has_codegen_attrs() {
608597
codegen_fn_attrs

‎compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ declare_features! (
387387
(accepted, struct_variant, "1.0.0", None),
388388
/// Allows `#[target_feature(...)]`.
389389
(accepted, target_feature, "1.27.0", None),
390+
/// Allows the use of `#[target_feature]` on safe functions.
391+
(accepted, target_feature_11, "CURRENT_RUSTC_VERSION", Some(69098)),
390392
/// Allows `fn main()` with return types which implements `Termination` (RFC 1937).
391393
(accepted, termination_trait, "1.26.0", Some(43301)),
392394
/// Allows `#[test]` functions where the return type implements `Termination` (RFC 1937).

‎compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,6 @@ declare_features! (
613613
(unstable, strict_provenance_lints, "1.61.0", Some(130351)),
614614
/// Allows string patterns to dereference values to match them.
615615
(unstable, string_deref_patterns, "1.67.0", Some(87121)),
616-
/// Allows the use of `#[target_feature]` on safe functions.
617-
(unstable, target_feature_11, "1.45.0", Some(69098)),
618616
/// Allows using `#[thread_local]` on `static` items.
619617
(unstable, thread_local, "1.0.0", Some(29594)),
620618
/// Allows defining `trait X = A + B;` alias items.

‎library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@
187187
#![feature(staged_api)]
188188
#![feature(stmt_expr_attributes)]
189189
#![feature(strict_provenance_lints)]
190-
#![feature(target_feature_11)]
191190
#![feature(trait_alias)]
192191
#![feature(transparent_unions)]
193192
#![feature(try_blocks)]

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

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

7-
#![feature(target_feature_11)]
87
#![crate_type = "rlib"]
98

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

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

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//@ compile-flags: -Copt-level=3 -Ctarget-cpu=x86-64
44

55
#![crate_type = "lib"]
6-
#![feature(target_feature_11)]
76

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

‎tests/mir-opt/inline/inline_compatibility.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#![crate_type = "lib"]
66
#![feature(no_sanitize)]
7-
#![feature(target_feature_11)]
87
#![feature(c_variadic)]
98

109
#[inline]

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

-2
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/async-await/async-closures/fn-exception-target-features.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
//@ edition: 2021
22
//@ only-x86_64
33

4-
#![feature(target_feature_11)]
5-
// `target_feature_11` just to test safe functions w/ target features.
6-
7-
use std::pin::Pin;
84
use std::future::Future;
5+
use std::pin::Pin;
96

107
#[target_feature(enable = "sse2")]
11-
fn target_feature() -> Pin<Box<dyn Future<Output = ()> + 'static>> { todo!() }
8+
fn target_feature() -> Pin<Box<dyn Future<Output = ()> + 'static>> {
9+
todo!()
10+
}
1211

1312
fn test(f: impl AsyncFn()) {}
1413

‎tests/ui/async-await/async-closures/fn-exception-target-features.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0277]: the trait bound `fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}: AsyncFn()` is not satisfied
2-
--> $DIR/fn-exception-target-features.rs:16:10
2+
--> $DIR/fn-exception-target-features.rs:15:10
33
|
44
LL | test(target_feature);
55
| ---- ^^^^^^^^^^^^^^ the trait `AsyncFn()` is not implemented for fn item `fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}`
66
| |
77
| required by a bound introduced by this call
88
|
99
note: required by a bound in `test`
10-
--> $DIR/fn-exception-target-features.rs:13:17
10+
--> $DIR/fn-exception-target-features.rs:12:17
1111
|
1212
LL | fn test(f: impl AsyncFn()) {}
1313
| ^^^^^^^^^ required by this bound in `test`

‎tests/ui/lang-items/start_lang_item_with_target_feature.rs

+1-1
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

-1
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

‎tests/ui/panic-handler/panic-handler-with-target-feature.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `#[panic_handler]` function is not allowed to have `#[target_feature]`
2-
--> $DIR/panic-handler-with-target-feature.rs:11:1
2+
--> $DIR/panic-handler-with-target-feature.rs:10:1
33
|
44
LL | #[target_feature(enable = "avx2")]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/rfcs/rfc-2396-target_feature-11/check-pass.rs

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
//@ check-pass
1010
//@ only-x86_64
1111

12-
#![feature(target_feature_11)]
13-
1412
#[target_feature(enable = "sse2")]
1513
const fn sse2() {}
1614

‎tests/ui/rfcs/rfc-2396-target_feature-11/closures-inherit-target_feature.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//@ check-pass
44
//@ only-x86_64
55

6-
#![feature(target_feature_11)]
7-
86
#[target_feature(enable = "avx")]
97
fn also_use_avx() {
108
println!("Hello from AVX")

‎tests/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.rs

-6
This file was deleted.

‎tests/ui/rfcs/rfc-2396-target_feature-11/feature-gate-target_feature_11.stderr

-15
This file was deleted.

‎tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ only-x86_64
22

3-
#![feature(target_feature_11)]
4-
53
#[target_feature(enable = "sse2")]
64
fn foo() {}
75

‎tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/fn-ptr.rs:9:21
2+
--> $DIR/fn-ptr.rs:7:21
33
|
44
LL | #[target_feature(enable = "sse2")]
55
| ---------------------------------- `#[target_feature]` added here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/fn-ptr.rs:9:21
3+
|
4+
LL | #[target_feature(enable = "sse2")]
5+
| ---------------------------------- `#[target_feature]` added here
6+
...
7+
LL | let foo: fn() = foo;
8+
| ---- ^^^ cannot coerce functions with `#[target_feature]` to safe function pointers
9+
| |
10+
| expected due to this
11+
|
12+
= note: expected fn pointer `fn()`
13+
found fn item `fn() {foo}`
14+
= note: fn items are distinct from fn pointers
15+
= note: functions with `#[target_feature]` can only be coerced to `unsafe` function pointers
16+
help: consider casting to a fn pointer
17+
|
18+
LL | let foo: fn() = foo as fn();
19+
| ~~~~~~~~~~~
20+
21+
error: aborting due to previous error
22+
23+
For more information about this error, try `rustc --explain E0308`.

‎tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ only-x86_64
22

3-
#![feature(target_feature_11)]
4-
53
#[target_feature(enable = "avx")]
64
fn foo() {}
75

‎tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: expected a `Fn()` closure, found `fn() {foo}`
2-
--> $DIR/fn-traits.rs:24:10
2+
--> $DIR/fn-traits.rs:22:10
33
|
44
LL | call(foo);
55
| ---- ^^^ expected an `Fn()` closure, found `fn() {foo}`
@@ -10,13 +10,13 @@ LL | call(foo);
1010
= note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }`
1111
= note: `#[target_feature]` functions do not implement the `Fn` traits
1212
note: required by a bound in `call`
13-
--> $DIR/fn-traits.rs:11:17
13+
--> $DIR/fn-traits.rs:9:17
1414
|
1515
LL | fn call(f: impl Fn()) {
1616
| ^^^^ required by this bound in `call`
1717

1818
error[E0277]: expected a `FnMut()` closure, found `fn() {foo}`
19-
--> $DIR/fn-traits.rs:25:14
19+
--> $DIR/fn-traits.rs:23:14
2020
|
2121
LL | call_mut(foo);
2222
| -------- ^^^ expected an `FnMut()` closure, found `fn() {foo}`
@@ -27,13 +27,13 @@ LL | call_mut(foo);
2727
= note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }`
2828
= note: `#[target_feature]` functions do not implement the `Fn` traits
2929
note: required by a bound in `call_mut`
30-
--> $DIR/fn-traits.rs:15:25
30+
--> $DIR/fn-traits.rs:13:25
3131
|
3232
LL | fn call_mut(mut f: impl FnMut()) {
3333
| ^^^^^^^ required by this bound in `call_mut`
3434

3535
error[E0277]: expected a `FnOnce()` closure, found `fn() {foo}`
36-
--> $DIR/fn-traits.rs:26:15
36+
--> $DIR/fn-traits.rs:24:15
3737
|
3838
LL | call_once(foo);
3939
| --------- ^^^ expected an `FnOnce()` closure, found `fn() {foo}`
@@ -44,13 +44,13 @@ LL | call_once(foo);
4444
= note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }`
4545
= note: `#[target_feature]` functions do not implement the `Fn` traits
4646
note: required by a bound in `call_once`
47-
--> $DIR/fn-traits.rs:19:22
47+
--> $DIR/fn-traits.rs:17:22
4848
|
4949
LL | fn call_once(f: impl FnOnce()) {
5050
| ^^^^^^^^ required by this bound in `call_once`
5151

5252
error[E0277]: expected a `Fn()` closure, found `unsafe fn() {foo_unsafe}`
53-
--> $DIR/fn-traits.rs:28:10
53+
--> $DIR/fn-traits.rs:26:10
5454
|
5555
LL | call(foo_unsafe);
5656
| ---- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
@@ -62,13 +62,13 @@ LL | call(foo_unsafe);
6262
= note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }`
6363
= note: `#[target_feature]` functions do not implement the `Fn` traits
6464
note: required by a bound in `call`
65-
--> $DIR/fn-traits.rs:11:17
65+
--> $DIR/fn-traits.rs:9:17
6666
|
6767
LL | fn call(f: impl Fn()) {
6868
| ^^^^ required by this bound in `call`
6969

7070
error[E0277]: expected a `FnMut()` closure, found `unsafe fn() {foo_unsafe}`
71-
--> $DIR/fn-traits.rs:30:14
71+
--> $DIR/fn-traits.rs:28:14
7272
|
7373
LL | call_mut(foo_unsafe);
7474
| -------- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
@@ -80,13 +80,13 @@ LL | call_mut(foo_unsafe);
8080
= note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }`
8181
= note: `#[target_feature]` functions do not implement the `Fn` traits
8282
note: required by a bound in `call_mut`
83-
--> $DIR/fn-traits.rs:15:25
83+
--> $DIR/fn-traits.rs:13:25
8484
|
8585
LL | fn call_mut(mut f: impl FnMut()) {
8686
| ^^^^^^^ required by this bound in `call_mut`
8787

8888
error[E0277]: expected a `FnOnce()` closure, found `unsafe fn() {foo_unsafe}`
89-
--> $DIR/fn-traits.rs:32:15
89+
--> $DIR/fn-traits.rs:30:15
9090
|
9191
LL | call_once(foo_unsafe);
9292
| --------- ^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
@@ -98,7 +98,7 @@ LL | call_once(foo_unsafe);
9898
= note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }`
9999
= note: `#[target_feature]` functions do not implement the `Fn` traits
100100
note: required by a bound in `call_once`
101-
--> $DIR/fn-traits.rs:19:22
101+
--> $DIR/fn-traits.rs:17:22
102102
|
103103
LL | fn call_once(f: impl FnOnce()) {
104104
| ^^^^^^^^ required by this bound in `call_once`
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ only-x86_64
22

3-
#![feature(target_feature_11)]
4-
53
#[target_feature(enable = "avx2")]
64
fn main() {}
75
//~^ ERROR `main` function is not allowed to have `#[target_feature]`

‎tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-main.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `main` function is not allowed to have `#[target_feature]`
2-
--> $DIR/issue-108645-target-feature-on-main.rs:6:1
2+
--> $DIR/issue-108645-target-feature-on-main.rs:4:1
33
|
44
LL | fn main() {}
55
| ^^^^^^^^^ `main` function is not allowed to have `#[target_feature]`

‎tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-start.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ only-x86_64
22

33
#![feature(start)]
4-
#![feature(target_feature_11)]
54

65
#[start]
76
#[target_feature(enable = "avx2")]

‎tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-start.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `#[start]` function is not allowed to have `#[target_feature]`
2-
--> $DIR/issue-108645-target-feature-on-start.rs:7:1
2+
--> $DIR/issue-108645-target-feature-on-start.rs:6:1
33
|
44
LL | #[target_feature(enable = "avx2")]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/rfcs/rfc-2396-target_feature-11/issue-108655-inline-always-closure.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//@ check-pass
44
//@ only-x86_64
55

6-
#![feature(target_feature_11)]
7-
86
#[target_feature(enable = "avx")]
97
pub unsafe fn test() {
108
({

‎tests/ui/rfcs/rfc-2396-target_feature-11/issue-99876.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ check-pass
22

3-
#![feature(target_feature_11)]
4-
53
struct S<T>(T)
64
where
75
[T; (|| {}, 1).1]: Copy;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
2+
--> $DIR/safe-calls.rs:21:5
3+
|
4+
LL | sse2();
5+
| ^^^^^^ call to function with `#[target_feature]`
6+
|
7+
= note: can only be called if the required target features are available
8+
9+
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
10+
--> $DIR/safe-calls.rs:24:5
11+
|
12+
LL | avx_bmi2();
13+
| ^^^^^^^^^^ call to function with `#[target_feature]`
14+
|
15+
= note: can only be called if the required target features are available
16+
17+
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
18+
--> $DIR/safe-calls.rs:27:5
19+
|
20+
LL | Quux.avx_bmi2();
21+
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
22+
|
23+
= note: can only be called if the required target features are available
24+
25+
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
26+
--> $DIR/safe-calls.rs:34:5
27+
|
28+
LL | avx_bmi2();
29+
| ^^^^^^^^^^ call to function with `#[target_feature]`
30+
|
31+
= note: can only be called if the required target features are available
32+
33+
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
34+
--> $DIR/safe-calls.rs:37:5
35+
|
36+
LL | Quux.avx_bmi2();
37+
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
38+
|
39+
= note: can only be called if the required target features are available
40+
41+
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
42+
--> $DIR/safe-calls.rs:44:5
43+
|
44+
LL | sse2();
45+
| ^^^^^^ call to function with `#[target_feature]`
46+
|
47+
= note: can only be called if the required target features are available
48+
49+
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
50+
--> $DIR/safe-calls.rs:47:5
51+
|
52+
LL | avx_bmi2();
53+
| ^^^^^^^^^^ call to function with `#[target_feature]`
54+
|
55+
= note: can only be called if the required target features are available
56+
57+
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
58+
--> $DIR/safe-calls.rs:50:5
59+
|
60+
LL | Quux.avx_bmi2();
61+
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
62+
|
63+
= note: can only be called if the required target features are available
64+
65+
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
66+
--> $DIR/safe-calls.rs:58:5
67+
|
68+
LL | sse2();
69+
| ^^^^^^ call to function with `#[target_feature]`
70+
|
71+
= note: can only be called if the required target features are available
72+
73+
error[E0133]: call to function with `#[target_feature]` is unsafe and requires unsafe function or block
74+
--> $DIR/safe-calls.rs:63:18
75+
|
76+
LL | const name: () = sse2();
77+
| ^^^^^^ call to function with `#[target_feature]`
78+
|
79+
= note: can only be called if the required target features are available
80+
81+
error: aborting due to 10 previous errors
82+
83+
For more information about this error, try `rustc --explain E0133`.

‎tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Set the base cpu explicitly, in case the default has been changed.
33
//@ compile-flags: -C target-cpu=x86-64
44

5-
#![feature(target_feature_11)]
6-
75
#[target_feature(enable = "sse2")]
86
const fn sse2() {}
97

‎tests/ui/rfcs/rfc-2396-target_feature-11/safe-calls.stderr

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
2-
--> $DIR/safe-calls.rs:27:5
2+
--> $DIR/safe-calls.rs:25:5
33
|
44
LL | sse2();
55
| ^^^^^^ call to function with `#[target_feature]`
@@ -8,55 +8,55 @@ LL | sse2();
88
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
99

1010
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
11-
--> $DIR/safe-calls.rs:29:5
11+
--> $DIR/safe-calls.rs:27:5
1212
|
1313
LL | avx_bmi2();
1414
| ^^^^^^^^^^ call to function with `#[target_feature]`
1515
|
1616
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
1717

1818
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
19-
--> $DIR/safe-calls.rs:31:5
19+
--> $DIR/safe-calls.rs:29:5
2020
|
2121
LL | Quux.avx_bmi2();
2222
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
2323
|
2424
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
2525

2626
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
27-
--> $DIR/safe-calls.rs:38:5
27+
--> $DIR/safe-calls.rs:36:5
2828
|
2929
LL | avx_bmi2();
3030
| ^^^^^^^^^^ call to function with `#[target_feature]`
3131
|
3232
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
3333

3434
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
35-
--> $DIR/safe-calls.rs:40:5
35+
--> $DIR/safe-calls.rs:38:5
3636
|
3737
LL | Quux.avx_bmi2();
3838
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
3939
|
4040
= help: in order for the call to be safe, the context requires the following additional target features: avx and bmi2
4141

4242
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
43-
--> $DIR/safe-calls.rs:47:5
43+
--> $DIR/safe-calls.rs:45:5
4444
|
4545
LL | avx_bmi2();
4646
| ^^^^^^^^^^ call to function with `#[target_feature]`
4747
|
4848
= help: in order for the call to be safe, the context requires the following additional target feature: bmi2
4949

5050
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
51-
--> $DIR/safe-calls.rs:49:5
51+
--> $DIR/safe-calls.rs:47:5
5252
|
5353
LL | Quux.avx_bmi2();
5454
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
5555
|
5656
= help: in order for the call to be safe, the context requires the following additional target feature: bmi2
5757

5858
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
59-
--> $DIR/safe-calls.rs:61:15
59+
--> $DIR/safe-calls.rs:59:15
6060
|
6161
LL | const _: () = sse2();
6262
| ^^^^^^ call to function with `#[target_feature]`
@@ -65,7 +65,7 @@ LL | const _: () = sse2();
6565
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
6666

6767
error[E0133]: call to function `sse2_and_fxsr` with `#[target_feature]` is unsafe and requires unsafe function or block
68-
--> $DIR/safe-calls.rs:64:15
68+
--> $DIR/safe-calls.rs:62:15
6969
|
7070
LL | const _: () = sse2_and_fxsr();
7171
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
@@ -74,7 +74,7 @@ LL | const _: () = sse2_and_fxsr();
7474
= note: the fxsr and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`
7575

7676
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe block
77-
--> $DIR/safe-calls.rs:69:5
77+
--> $DIR/safe-calls.rs:67:5
7878
|
7979
LL | sse2();
8080
| ^^^^^^ call to function with `#[target_feature]`
@@ -83,12 +83,12 @@ LL | sse2();
8383
= help: in order for the call to be safe, the context requires the following additional target feature: sse2
8484
= note: the sse2 target feature being enabled in the build configuration does not remove the requirement to list it in `#[target_feature]`
8585
note: an unsafe function restricts its caller, but its body is safe by default
86-
--> $DIR/safe-calls.rs:68:1
86+
--> $DIR/safe-calls.rs:66:1
8787
|
8888
LL | unsafe fn needs_unsafe_block() {
8989
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9090
note: the lint level is defined here
91-
--> $DIR/safe-calls.rs:67:8
91+
--> $DIR/safe-calls.rs:65:8
9292
|
9393
LL | #[deny(unsafe_op_in_unsafe_fn)]
9494
| ^^^^^^^^^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
2+
--> $DIR/safe-calls.rs:21:5
3+
|
4+
LL | sse2();
5+
| ^^^^^^ call to function with `#[target_feature]`
6+
|
7+
= note: can only be called if the required target features are available
8+
9+
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
10+
--> $DIR/safe-calls.rs:24:5
11+
|
12+
LL | avx_bmi2();
13+
| ^^^^^^^^^^ call to function with `#[target_feature]`
14+
|
15+
= note: can only be called if the required target features are available
16+
17+
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
18+
--> $DIR/safe-calls.rs:27:5
19+
|
20+
LL | Quux.avx_bmi2();
21+
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
22+
|
23+
= note: can only be called if the required target features are available
24+
25+
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
26+
--> $DIR/safe-calls.rs:34:5
27+
|
28+
LL | avx_bmi2();
29+
| ^^^^^^^^^^ call to function with `#[target_feature]`
30+
|
31+
= note: can only be called if the required target features are available
32+
33+
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
34+
--> $DIR/safe-calls.rs:37:5
35+
|
36+
LL | Quux.avx_bmi2();
37+
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
38+
|
39+
= note: can only be called if the required target features are available
40+
41+
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
42+
--> $DIR/safe-calls.rs:44:5
43+
|
44+
LL | sse2();
45+
| ^^^^^^ call to function with `#[target_feature]`
46+
|
47+
= note: can only be called if the required target features are available
48+
49+
error[E0133]: call to function `avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
50+
--> $DIR/safe-calls.rs:47:5
51+
|
52+
LL | avx_bmi2();
53+
| ^^^^^^^^^^ call to function with `#[target_feature]`
54+
|
55+
= note: can only be called if the required target features are available
56+
57+
error[E0133]: call to function `Quux::avx_bmi2` with `#[target_feature]` is unsafe and requires unsafe function or block
58+
--> $DIR/safe-calls.rs:50:5
59+
|
60+
LL | Quux.avx_bmi2();
61+
| ^^^^^^^^^^^^^^^ call to function with `#[target_feature]`
62+
|
63+
= note: can only be called if the required target features are available
64+
65+
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
66+
--> $DIR/safe-calls.rs:58:5
67+
|
68+
LL | sse2();
69+
| ^^^^^^ call to function with `#[target_feature]`
70+
|
71+
= note: can only be called if the required target features are available
72+
73+
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe function or block
74+
--> $DIR/safe-calls.rs:63:18
75+
|
76+
LL | const name: () = sse2();
77+
| ^^^^^^ call to function with `#[target_feature]`
78+
|
79+
= note: can only be called if the required target features are available
80+
81+
error: aborting due to 10 previous errors
82+
83+
For more information about this error, try `rustc --explain E0133`.

‎tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ only-x86_64
22

3-
#![feature(target_feature_11)]
4-
53
trait Foo {
64
fn foo(&self);
75
unsafe fn unsf_foo(&self);

‎tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `#[target_feature(..)]` cannot be applied to safe trait method
2-
--> $DIR/trait-impl.rs:13:5
2+
--> $DIR/trait-impl.rs:11:5
33
|
44
LL | #[target_feature(enable = "sse2")]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method
@@ -8,7 +8,7 @@ LL | fn foo(&self) {}
88
| ------------- not an `unsafe` function
99

1010
error: `#[target_feature(..)]` cannot be applied to safe trait method
11-
--> $DIR/trait-impl.rs:22:5
11+
--> $DIR/trait-impl.rs:20:5
1212
|
1313
LL | #[target_feature(enable = "sse2")]
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method

‎tests/ui/simd-abi-checks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#![feature(avx512_target_feature)]
66
#![feature(portable_simd)]
7-
#![feature(target_feature_11, simd_ffi)]
7+
#![feature(simd_ffi)]
88
#![allow(improper_ctypes_definitions)]
99

1010
use std::arch::x86_64::*;

‎tests/ui/target-feature/implied-features.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ only-x86_64
22
//@ build-pass
3-
#![feature(target_feature_11)]
43
#![allow(dead_code)]
54

65
#[target_feature(enable = "ssse3")]

‎tests/ui/target-feature/invalid-attribute.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ extern "Rust" {}
2828
//~^ ERROR malformed `target_feature` attribute
2929
unsafe fn foo() {}
3030

31-
#[target_feature(enable = "sse2")]
32-
//~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
33-
//~| NOTE see issue #69098
34-
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
35-
fn bar() {}
36-
//~^ NOTE not an `unsafe` function
37-
3831
#[target_feature(enable = "sse2")]
3932
//~^ ERROR attribute should be applied to a function
4033
mod another {}
@@ -58,7 +51,7 @@ enum Bar {}
5851
#[target_feature(enable = "sse2")]
5952
//~^ ERROR attribute should be applied to a function
6053
union Qux {
61-
//~^ NOTE not a function
54+
//~^ NOTE not a function
6255
f1: u16,
6356
f2: u16,
6457
}
@@ -101,9 +94,8 @@ trait Quux {
10194

10295
impl Quux for Foo {
10396
#[target_feature(enable = "sse2")]
104-
//~^ ERROR `#[target_feature(..)]` can only be applied to `unsafe` functions
105-
//~| NOTE see issue #69098
106-
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
97+
//~^ ERROR `#[target_feature(..)]` cannot be applied to safe trait method
98+
//~| NOTE cannot be applied to safe trait method
10799
fn foo() {}
108100
//~^ NOTE not an `unsafe` function
109101
}
@@ -113,9 +105,8 @@ fn main() {
113105
//~^ ERROR attribute should be applied to a function
114106
unsafe {
115107
foo();
116-
bar();
117108
}
118-
//~^^^^ NOTE not a function
109+
//~^^^ NOTE not a function
119110

120111
#[target_feature(enable = "sse2")]
121112
//~^ ERROR attribute should be applied to a function

‎tests/ui/target-feature/invalid-attribute.stderr

+19-38
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ LL | extern "Rust" {}
3232
| ---------------- not a function definition
3333

3434
error: attribute should be applied to a function definition
35-
--> $DIR/invalid-attribute.rs:38:1
35+
--> $DIR/invalid-attribute.rs:31:1
3636
|
3737
LL | #[target_feature(enable = "sse2")]
3838
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -41,7 +41,7 @@ LL | mod another {}
4141
| -------------- not a function definition
4242

4343
error: attribute should be applied to a function definition
44-
--> $DIR/invalid-attribute.rs:43:1
44+
--> $DIR/invalid-attribute.rs:36:1
4545
|
4646
LL | #[target_feature(enable = "sse2")]
4747
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -50,7 +50,7 @@ LL | const FOO: usize = 7;
5050
| --------------------- not a function definition
5151

5252
error: attribute should be applied to a function definition
53-
--> $DIR/invalid-attribute.rs:48:1
53+
--> $DIR/invalid-attribute.rs:41:1
5454
|
5555
LL | #[target_feature(enable = "sse2")]
5656
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -59,7 +59,7 @@ LL | struct Foo;
5959
| ----------- not a function definition
6060

6161
error: attribute should be applied to a function definition
62-
--> $DIR/invalid-attribute.rs:53:1
62+
--> $DIR/invalid-attribute.rs:46:1
6363
|
6464
LL | #[target_feature(enable = "sse2")]
6565
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -68,7 +68,7 @@ LL | enum Bar {}
6868
| ----------- not a function definition
6969

7070
error: attribute should be applied to a function definition
71-
--> $DIR/invalid-attribute.rs:58:1
71+
--> $DIR/invalid-attribute.rs:51:1
7272
|
7373
LL | #[target_feature(enable = "sse2")]
7474
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -81,7 +81,7 @@ LL | | }
8181
| |_- not a function definition
8282

8383
error: attribute should be applied to a function definition
84-
--> $DIR/invalid-attribute.rs:66:1
84+
--> $DIR/invalid-attribute.rs:59:1
8585
|
8686
LL | #[target_feature(enable = "sse2")]
8787
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -90,7 +90,7 @@ LL | type Uwu = ();
9090
| -------------- not a function definition
9191

9292
error: attribute should be applied to a function definition
93-
--> $DIR/invalid-attribute.rs:71:1
93+
--> $DIR/invalid-attribute.rs:64:1
9494
|
9595
LL | #[target_feature(enable = "sse2")]
9696
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -99,7 +99,7 @@ LL | trait Baz {}
9999
| ------------ not a function definition
100100

101101
error: attribute should be applied to a function definition
102-
--> $DIR/invalid-attribute.rs:81:1
102+
--> $DIR/invalid-attribute.rs:74:1
103103
|
104104
LL | #[target_feature(enable = "sse2")]
105105
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -108,7 +108,7 @@ LL | static A: () = ();
108108
| ------------------ not a function definition
109109

110110
error: attribute should be applied to a function definition
111-
--> $DIR/invalid-attribute.rs:86:1
111+
--> $DIR/invalid-attribute.rs:79:1
112112
|
113113
LL | #[target_feature(enable = "sse2")]
114114
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -117,7 +117,7 @@ LL | impl Quux for u8 {}
117117
| ------------------- not a function definition
118118

119119
error: attribute should be applied to a function definition
120-
--> $DIR/invalid-attribute.rs:93:1
120+
--> $DIR/invalid-attribute.rs:86:1
121121
|
122122
LL | #[target_feature(enable = "sse2")]
123123
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -126,19 +126,18 @@ LL | impl Foo {}
126126
| ----------- not a function definition
127127

128128
error: attribute should be applied to a function definition
129-
--> $DIR/invalid-attribute.rs:112:5
129+
--> $DIR/invalid-attribute.rs:104:5
130130
|
131131
LL | #[target_feature(enable = "sse2")]
132132
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
133133
LL |
134134
LL | / unsafe {
135135
LL | | foo();
136-
LL | | bar();
137136
LL | | }
138137
| |_____- not a function definition
139138

140139
error: attribute should be applied to a function definition
141-
--> $DIR/invalid-attribute.rs:120:5
140+
--> $DIR/invalid-attribute.rs:111:5
142141
|
143142
LL | #[target_feature(enable = "sse2")]
144143
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -164,48 +163,30 @@ error: malformed `target_feature` attribute input
164163
LL | #[target_feature(disable = "baz")]
165164
| ^^^^^^^^^^^^^^^ help: must be of the form: `enable = ".."`
166165

167-
error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions
168-
--> $DIR/invalid-attribute.rs:31:1
169-
|
170-
LL | #[target_feature(enable = "sse2")]
171-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
172-
...
173-
LL | fn bar() {}
174-
| -------- not an `unsafe` function
175-
|
176-
= note: see issue #69098 <https://github.com/rust-lang/rust/issues/69098> for more information
177-
= help: add `#![feature(target_feature_11)]` to the crate attributes to enable
178-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
179-
180166
error: cannot use `#[inline(always)]` with `#[target_feature]`
181-
--> $DIR/invalid-attribute.rs:76:1
167+
--> $DIR/invalid-attribute.rs:69:1
182168
|
183169
LL | #[inline(always)]
184170
| ^^^^^^^^^^^^^^^^^
185171

186172
error[E0046]: not all trait items implemented, missing: `foo`
187-
--> $DIR/invalid-attribute.rs:88:1
173+
--> $DIR/invalid-attribute.rs:81:1
188174
|
189175
LL | impl Quux for u8 {}
190176
| ^^^^^^^^^^^^^^^^ missing `foo` in implementation
191177
...
192178
LL | fn foo();
193179
| --------- `foo` from trait
194180

195-
error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions
196-
--> $DIR/invalid-attribute.rs:103:5
181+
error: `#[target_feature(..)]` cannot be applied to safe trait method
182+
--> $DIR/invalid-attribute.rs:96:5
197183
|
198184
LL | #[target_feature(enable = "sse2")]
199-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
185+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method
200186
...
201187
LL | fn foo() {}
202188
| -------- not an `unsafe` function
203-
|
204-
= note: see issue #69098 <https://github.com/rust-lang/rust/issues/69098> for more information
205-
= help: add `#![feature(target_feature_11)]` to the crate attributes to enable
206-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
207189

208-
error: aborting due to 23 previous errors
190+
error: aborting due to 22 previous errors
209191

210-
Some errors have detailed explanations: E0046, E0658.
211-
For more information about an error, try `rustc --explain E0046`.
192+
For more information about this error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)
Please sign in to comment.