Open
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