mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
b583ede652
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/`](
|
||
---|---|---|
.. | ||
asm_unwind.main.Inline.diff | ||
asm_unwind.rs | ||
caller_with_trivial_bound.foo.Inline.diff | ||
caller_with_trivial_bound.rs | ||
cycle.f.Inline.diff | ||
cycle.g.Inline.diff | ||
cycle.main.Inline.diff | ||
cycle.rs | ||
dyn_trait.get_query.Inline.diff | ||
dyn_trait.mk_cycle.Inline.diff | ||
dyn_trait.rs | ||
dyn_trait.try_execute_query.Inline.diff | ||
exponential_runtime.main.Inline.diff | ||
exponential_runtime.rs | ||
inline_any_operand.bar.Inline.after.mir | ||
inline_any_operand.rs | ||
inline_async.rs | ||
inline_closure_borrows_arg.foo.Inline.after.mir | ||
inline_closure_borrows_arg.rs | ||
inline_closure_captures.foo.Inline.after.mir | ||
inline_closure_captures.rs | ||
inline_closure.foo.Inline.after.mir | ||
inline_closure.rs | ||
inline_compatibility.inlined_no_sanitize.Inline.diff | ||
inline_compatibility.inlined_target_feature.Inline.diff | ||
inline_compatibility.not_inlined_c_variadic.Inline.diff | ||
inline_compatibility.not_inlined_no_sanitize.Inline.diff | ||
inline_compatibility.not_inlined_target_feature.Inline.diff | ||
inline_compatibility.rs | ||
inline_cycle_generic.main.Inline.diff | ||
inline_cycle_generic.rs | ||
inline_cycle.one.Inline.diff | ||
inline_cycle.rs | ||
inline_cycle.two.Inline.diff | ||
inline_diverging.f.Inline.diff | ||
inline_diverging.g.Inline.diff | ||
inline_diverging.h.Inline.diff | ||
inline_diverging.rs | ||
inline_generator.main.Inline.diff | ||
inline_generator.rs | ||
inline_instruction_set.default.Inline.diff | ||
inline_instruction_set.rs | ||
inline_instruction_set.t32.Inline.diff | ||
inline_into_box_place.main.Inline.diff | ||
inline_into_box_place.rs | ||
inline_options.main.Inline.after.mir | ||
inline_options.rs | ||
inline_retag.bar.Inline.after.mir | ||
inline_retag.rs | ||
inline_shims.clone.Inline.diff | ||
inline_shims.drop.Inline.diff | ||
inline_shims.rs | ||
inline_specialization.main.Inline.diff | ||
inline_specialization.rs | ||
inline_trait_method_2.rs | ||
inline_trait_method_2.test2.Inline.after.mir | ||
inline_trait_method.rs | ||
inline_trait_method.test.Inline.after.mir | ||
issue_58867_inline_as_ref_as_mut.a.Inline.after.mir | ||
issue_58867_inline_as_ref_as_mut.b.Inline.after.mir | ||
issue_58867_inline_as_ref_as_mut.c.Inline.after.mir | ||
issue_58867_inline_as_ref_as_mut.d.Inline.after.mir | ||
issue_58867_inline_as_ref_as_mut.rs | ||
issue_76997_inline_scopes_parenting.main.Inline.after.mir | ||
issue_76997_inline_scopes_parenting.rs | ||
issue_78442.bar.Inline.diff | ||
issue_78442.bar.RevealAll.diff | ||
issue_78442.rs | ||
issue_106141.outer.Inline.diff | ||
issue_106141.rs | ||
polymorphic_recursion.rs |