Skip to content

Tracking issue for release notes of #134090: Stabilize target_feature_11 #136058

Closed
@rustbot

Description

@rustbot
Collaborator

This issue tracks the release notes text for #134090.

Steps

  • Proposed text is drafted by PR author (or team) making the noteworthy change.
    Issue is nominated for release team review of clarity for wider audience.
    Release team includes text in release notes/blog posts.

Release notes text

The responsible team for the underlying change should edit this section to replace the automatically generated link with a succinct description of what changed, drawing upon text proposed by the author (either in discussion or through direct editing).

# Language
- [Allow safe functions to be marked with the `#[target_feature]` attribute.](https://github.com/rust-lang/rust/pull/134090)

Tip

Use the previous releases categories to help choose which one(s) to use.
The category will be de-duplicated with all the other ones by the release team.

More than one section can be included if needed.

Release blog section

If the change is notable enough for inclusion in the blog post, the responsible team should add content to this section.
Otherwise leave it empty.

Functions marked with `#[target_feature]` are generally considered as unsafe functions: they are unsafe to call, cannot *generally* 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();
}
```

cc @veluca93, @tmandry -- origin issue/PR authors and assignees for starting to draft text

Activity

added
relnotesMarks issues that should be documented in the release notes of the next release.
relnotes-tracking-issueMarks issues tracking what text to put in release notes.
T-langRelevant to the language team
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Jan 25, 2025
veluca93

veluca93 commented on Jan 30, 2025

@veluca93
Contributor

(I can't edit the main comment, so I will write here.)

Category: Language
Title: Allow safe functions to be marked with the #[target_feature] attribute.

Possible blog content (taken from the stabilization PR, which contains more details):

Functions marked with #[target_feature] are generally considered as unsafe functions: they are unsafe to call, cannot generally 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.

// 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();
}
added this to the 1.86.0 milestone on Feb 13, 2025
added
release-blog-postMarks issues tracking what text to put in the release blog post.
on Mar 21, 2025
added
A-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.
A-attributesArea: Attributes (`#[…]`, `#![…]`)
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Mar 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamrelease-blog-postMarks issues tracking what text to put in the release blog post.relnotesMarks issues that should be documented in the release notes of the next release.relnotes-tracking-issueMarks issues tracking what text to put in release notes.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @cuviper@veluca93@BoxyUwU@jieyouxu@rustbot

        Issue actions

          Tracking issue for release notes of #134090: Stabilize target_feature_11 · Issue #136058 · rust-lang/rust