rust/tests/ui/asm
bors b583ede652 Auto merge of #99767 - LeSeulArtichaut:stable-target-feature-11, r=estebank
Stabilize `#![feature(target_feature_11)]`

## Stabilization report

### Summary

Allows for safe functions to be marked with `#[target_feature]` attributes.

Functions marked with `#[target_feature]` are generally considered as unsafe functions: they are unsafe to call, cannot be assigned to safe function pointers, and don't implement the `Fn*` traits.

However, calling them from other `#[target_feature]` functions with a superset of features is safe.

```rust
// Demonstration function
#[target_feature(enable = "avx2")]
fn avx2() {}

fn foo() {
    // Calling `avx2` here is unsafe, as we must ensure
    // that AVX is available first.
    unsafe {
        avx2();
    }
}

#[target_feature(enable = "avx2")]
fn bar() {
    // Calling `avx2` here is safe.
    avx2();
}
```

### Test cases

Tests for this feature can be found in [`src/test/ui/rfcs/rfc-2396-target_feature-11/`](b67ba9ba20/src/test/ui/rfcs/rfc-2396-target_feature-11/).

### Edge cases

- https://github.com/rust-lang/rust/issues/73631

Closures defined inside functions marked with `#[target_feature]` inherit the target features of their parent function. They can still be assigned to safe function pointers and implement the appropriate `Fn*` traits.

```rust
#[target_feature(enable = "avx2")]
fn qux() {
    let my_closure = || avx2(); // this call to `avx2` is safe
    let f: fn() = my_closure;
}
```

This means that in order to call a function with `#[target_feature]`, you must show that the target-feature is available while the function executes *and* for as long as whatever may escape from that function lives.

### Documentation

- Reference: https://github.com/rust-lang/reference/pull/1181

---
cc tracking issue #69098
r? `@ghost`
2023-02-28 01:14:56 +00:00
..
aarch64 Move /src/test to /tests 2023-01-11 09:32:08 +00:00
x86_64 Stabilize #![feature(target_feature_11)] 2023-02-01 08:53:02 +01:00
bad-arch.mirunsafeck.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bad-arch.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bad-arch.thirunsafeck.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bad-template.aarch64_mirunsafeck.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bad-template.aarch64_thirunsafeck.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bad-template.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bad-template.x86_64_mirunsafeck.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bad-template.x86_64_thirunsafeck.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic-const.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline-syntax.arm.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline-syntax.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline-syntax.x86_64.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-72570.rs Remove save-analysis. 2023-02-16 15:14:45 +11:00
issue-72570.stderr Remove save-analysis. 2023-02-16 15:14:45 +11:00
issue-85247.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-85247.rwpi.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-87802.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-87802.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-89305.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-89305.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-92378.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-97490.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-99071.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-99071.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-99122-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-99122.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-99122.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
may_unwind.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-functions-ffi.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-functions-ffi.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-functions-unused.aarch64.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-functions-unused.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-functions-unused.x86_64.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-functions.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-functions.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-invalid-attr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
naked-invalid-attr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
named-asm-labels.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
named-asm-labels.s Move /src/test to /tests 2023-01-11 09:32:08 +00:00
named-asm-labels.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
noreturn.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
reg-conflict.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
reg-conflict.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
type-check-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
type-check-1.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
type-check-4.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
type-check-4.stderr Tweak E0597 2023-01-15 19:46:20 +00:00
unpretty-expanded.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unpretty-expanded.stdout Move /src/test to /tests 2023-01-11 09:32:08 +00:00