target_feature leads to confusing note in rustdoc
@lolbinarycat is already working on this.
Since Oct 19, 2024.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
#[target_feature(enable = "avx2")]
pub unsafe fn f() {}
I expected to see this happen:
Rustdoc says something along the lines of:
Requires target feature avx2 at runtime.
Instead, this happened:
Rustdoc says:
Available with target feature avx2 only.
It is not clear what “available” means here. I initially thought it meant the function would not be defined if not compiled with --codegen target-feature=+avx2 (and concluded it was always safe to call if the calling program compiles). Instead it means the function is always defined but must not be called if the target feature is not available at runtime. Rustdoc gives no other indication that the target_feature attribute is used, and the note looks a lot like the “available on create feature … only” notes.
Meta
rustc --version --verbose:
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.