rust/tests/mir-opt/inline
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
..
asm_unwind.main.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
asm_unwind.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
caller_with_trivial_bound.foo.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
caller_with_trivial_bound.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cycle.f.Inline.diff Bless tests. 2023-02-02 23:26:26 +00:00
cycle.g.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cycle.main.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cycle.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dyn_trait.get_query.Inline.diff Implement SSA CopyProp pass. 2023-01-27 18:22:45 +00:00
dyn_trait.mk_cycle.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dyn_trait.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dyn_trait.try_execute_query.Inline.diff Implement SSA CopyProp pass. 2023-01-27 18:22:45 +00:00
exponential_runtime.main.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
exponential_runtime.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_any_operand.bar.Inline.after.mir Implement SSA CopyProp pass. 2023-01-27 18:22:45 +00:00
inline_any_operand.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_async.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_closure_borrows_arg.foo.Inline.after.mir Bless tests. 2023-02-02 23:26:26 +00:00
inline_closure_borrows_arg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_closure_captures.foo.Inline.after.mir Bless tests. 2023-02-02 23:26:26 +00:00
inline_closure_captures.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_closure.foo.Inline.after.mir Bless tests. 2023-02-02 23:26:26 +00:00
inline_closure.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_compatibility.inlined_no_sanitize.Inline.diff Stabilize #![feature(target_feature_11)] 2023-02-01 08:53:02 +01:00
inline_compatibility.inlined_target_feature.Inline.diff Stabilize #![feature(target_feature_11)] 2023-02-01 08:53:02 +01:00
inline_compatibility.not_inlined_c_variadic.Inline.diff Stabilize #![feature(target_feature_11)] 2023-02-01 08:53:02 +01:00
inline_compatibility.not_inlined_no_sanitize.Inline.diff Stabilize #![feature(target_feature_11)] 2023-02-01 08:53:02 +01:00
inline_compatibility.not_inlined_target_feature.Inline.diff Stabilize #![feature(target_feature_11)] 2023-02-01 08:53:02 +01:00
inline_compatibility.rs Stabilize #![feature(target_feature_11)] 2023-02-01 08:53:02 +01:00
inline_cycle_generic.main.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_cycle_generic.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_cycle.one.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_cycle.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_cycle.two.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_diverging.f.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_diverging.g.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_diverging.h.Inline.diff Bless tests. 2023-02-02 23:26:26 +00:00
inline_diverging.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_generator.main.Inline.diff Enable CopyProp by default, tune the impl a bit 2023-02-12 13:23:53 -05:00
inline_generator.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_instruction_set.default.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_instruction_set.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_instruction_set.t32.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_into_box_place.main.Inline.diff Bless tests. 2023-02-02 23:26:26 +00:00
inline_into_box_place.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_options.main.Inline.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_options.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_retag.bar.Inline.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_retag.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_shims.clone.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_shims.drop.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_shims.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_specialization.main.Inline.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_specialization.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_trait_method_2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_trait_method_2.test2.Inline.after.mir Implement SSA CopyProp pass. 2023-01-27 18:22:45 +00:00
inline_trait_method.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline_trait_method.test.Inline.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_58867_inline_as_ref_as_mut.a.Inline.after.mir Enable instcombine for mutable reborrows 2023-02-16 07:51:23 -05:00
issue_58867_inline_as_ref_as_mut.b.Inline.after.mir Enable instcombine for mutable reborrows 2023-02-16 07:51:23 -05:00
issue_58867_inline_as_ref_as_mut.c.Inline.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_58867_inline_as_ref_as_mut.d.Inline.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_58867_inline_as_ref_as_mut.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_76997_inline_scopes_parenting.main.Inline.after.mir Bless tests. 2023-02-02 23:26:26 +00:00
issue_76997_inline_scopes_parenting.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_78442.bar.Inline.diff Bless tests. 2023-02-02 23:26:26 +00:00
issue_78442.bar.RevealAll.diff Bless tests. 2023-02-02 23:26:26 +00:00
issue_78442.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_106141.outer.Inline.diff Make the inlining destination a Local. 2023-01-14 12:09:06 +00:00
issue_106141.rs Make the inlining destination a Local. 2023-01-14 12:09:06 +00:00
polymorphic_recursion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00