Skip to content

std: Clean up and improve errors for is_*_feature_detected macros - #165011

Open
tgross35 wants to merge 5 commits into
rust-lang:mainfrom
tgross35:std_detect-updates
Open

tgross35 wants to merge 5 commits into
rust-lang:mainfrom
tgross35:std_detect-updates

Conversation

@tgross35

@tgross35 tgross35 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

View all comments

This includes a handful of small changes around the internals of our feature detection macros:

This is done in a handful of separate commits, the messages have some more details.

r? libs

@rustbot

rustbot commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in std_detect

cc @Amanieu, @folkertdev, @sayantn

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 27, 2026
@tgross35

Copy link
Copy Markdown
Member Author

@bors try jobs=test-i686-gnu-1,test-i686-gnu-2

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 27, 2026
std: Clean up and improve errors for `is_*_feature_detected` macros


try-job: test-i686-gnu-1
try-job: test-i686-gnu-2
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 27, 2026
@rust-bors

This comment was marked as outdated.

@tgross35

This comment was marked as outdated.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 27, 2026
std: Clean up and improve errors for `is_*_feature_detected` macros


try-job: test-i686-gnu-1
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment was marked as outdated.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@tgross35

This comment was marked as outdated.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 27, 2026
std: Clean up and improve errors for `is_*_feature_detected` macros


try-job: test-i686-gnu-1
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment was marked as outdated.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

It can be a bit tricky to follow these macros, but we still want to
provide good diagnostics. Add tests making sure these don't change.
Because of rewrapping, this prints as:

    error: This macro cannot be used on the current target.
                                       You can prevent it from being used in other architectures by
                                       guarding it behind a cfg(any(target_arch = "aarch64", target_arch = "arm64ec")).

Bridge newlines so it instead prints as this: 

    error: This macro cannot be used on the current target. You can prevent
           it from being used in other architectures by guarding it behind
           a `cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))`.
We have a handful of `#[unstable]` gates that aren't even being used,
because all that matters is the re-export in `std`. For example, the
RISC-V macro appears unstable, but has actually been stable since 1.78
<https://doc.rust-lang.org/1.78.0/std/arch/macro.is_riscv_feature_detected.html>.
@tgross35

Copy link
Copy Markdown
Member Author

@bors try jobs=test-i686-gnu-1

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 27, 2026
std: Clean up and improve errors for `is_*_feature_detected` macros


try-job: test-i686-gnu-1
@rust-bors

rust-bors Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: a0dd189 (a0dd189f4a59792f71fc63cf586e0700c11752ff)
Base parent: 16d1ffa (16d1ffac17ad8b739e32483ac2e65fe7e1804977)

@tgross35

Copy link
Copy Markdown
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 27, 2026
Rather than transmuting discriminants, use the macros to generate a list
of all features that we can iterate instead. This also allows us to
remove the sentinel `_last` entry.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants