Skip to content

target_feature leads to confusing note in rustdoc #131735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zopsicle opened this issue Oct 15, 2024 · 1 comment
Open

target_feature leads to confusing note in rustdoc #131735

zopsicle opened this issue Oct 15, 2024 · 1 comment
Assignees
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Comments

@zopsicle
Copy link
Contributor

zopsicle commented Oct 15, 2024

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
@zopsicle zopsicle added the C-bug Category: This is a bug. label Oct 15, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 15, 2024
@jieyouxu jieyouxu added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 15, 2024
@lolbinarycat lolbinarycat self-assigned this Oct 19, 2024
@lolbinarycat
Copy link
Contributor

rustdoc currently treats #[target_feature(enable = "feat")] as equivalent to #[doc(cfg(target_feature = "feat"))]. which is a problem since they do different things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

No branches or pull requests

4 participants