Skip to content

Commit bc911c2

Browse files
committed
std-detect: improve detect macro docs
document that the detect macros expand to `true` when the feature is statically enabled
1 parent 5413f7d commit bc911c2

File tree

10 files changed

+45
-17
lines changed

10 files changed

+45
-17
lines changed

library/std_detect/src/detect/arch/aarch64.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ features! {
55
@CFG: any(target_arch = "aarch64", target_arch = "arm64ec");
66
@MACRO_NAME: is_aarch64_feature_detected;
77
@MACRO_ATTRS:
8-
/// This macro tests, at runtime, whether an `aarch64` feature is enabled on aarch64 platforms.
9-
/// Currently most features are only supported on linux-based platforms.
8+
/// Check for the presence of a CPU feature at runtime.
9+
///
10+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
11+
/// the macro expands to `true`.
1012
///
1113
/// This macro takes one argument which is a string literal of the feature being tested for.
1214
/// The feature names are mostly taken from their FEAT_* definitions in the [ARM Architecture
1315
/// Reference Manual][docs].
1416
///
17+
/// Currently most features are only supported on linux-based platforms: on other platforms the
18+
/// runtime check will always return `false`.
19+
///
1520
/// ## Supported arguments
1621
///
1722
/// * `"aes"` - FEAT_AES & FEAT_PMULL

library/std_detect/src/detect/arch/arm.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ features! {
55
@CFG: target_arch = "arm";
66
@MACRO_NAME: is_arm_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `arm` feature is enabled.
8+
/// Check for the presence of a CPU feature at runtime.
9+
///
10+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
11+
/// the macro expands to `true`.
912
#[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")]
1013
@NO_RUNTIME_DETECTION: "v7";
1114
@NO_RUNTIME_DETECTION: "vfp2";

library/std_detect/src/detect/arch/loongarch.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ features! {
55
@CFG: any(target_arch = "loongarch32", target_arch = "loongarch64");
66
@MACRO_NAME: is_loongarch_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `loongarch` feature is enabled.
8+
/// Check for the presence of a CPU feature at runtime.
9+
///
10+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
11+
/// the macro expands to `true`.
12+
///
913
/// Supported arguments are:
1014
///
1115
/// * `"32s"`

library/std_detect/src/detect/arch/mips.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ features! {
55
@CFG: target_arch = "mips";
66
@MACRO_NAME: is_mips_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `mips` feature is enabled.
8+
/// Check for the presence of a CPU feature at runtime.
9+
///
10+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
11+
/// the macro expands to `true`.
912
#[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")]
1013
@FEATURE: #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] msa: "msa";
1114
/// MIPS SIMD Architecture (MSA)

library/std_detect/src/detect/arch/mips64.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ features! {
55
@CFG: target_arch = "mips64";
66
@MACRO_NAME: is_mips64_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `mips64` feature is enabled.
8+
/// Check for the presence of a CPU feature at runtime.
9+
///
10+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
11+
/// the macro expands to `true`.
912
#[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")]
1013
@FEATURE: #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] msa: "msa";
1114
/// MIPS SIMD Architecture (MSA)

library/std_detect/src/detect/arch/powerpc.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ features! {
55
@CFG: target_arch = "powerpc";
66
@MACRO_NAME: is_powerpc_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `powerpc` feature is enabled.
8+
/// Check for the presence of a CPU feature at runtime.
9+
///
10+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
11+
/// the macro expands to `true`.
912
#[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")]
1013
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] altivec: "altivec";
1114
/// Altivec

library/std_detect/src/detect/arch/powerpc64.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ features! {
55
@CFG: target_arch = "powerpc64";
66
@MACRO_NAME: is_powerpc64_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `powerpc` feature is enabled.
8+
/// Check for the presence of a CPU feature at runtime.
9+
///
10+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
11+
/// the macro expands to `true`.
912
#[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")]
1013
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] altivec: "altivec";
1114
/// Altivec

library/std_detect/src/detect/arch/riscv.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ features! {
55
@CFG: any(target_arch = "riscv32", target_arch = "riscv64");
66
@MACRO_NAME: is_riscv_feature_detected;
77
@MACRO_ATTRS:
8-
/// A macro to test at *runtime* whether instruction sets are available on
9-
/// RISC-V platforms.
8+
/// Check for the presence of a CPU feature at runtime.
9+
///
10+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
11+
/// the macro expands to `true`.
1012
///
1113
/// RISC-V standard defined the base sets and the extension sets.
1214
/// The base sets are RV32I, RV64I, RV32E or RV128I. Any RISC-V platform

library/std_detect/src/detect/arch/s390x.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ features! {
55
@CFG: target_arch = "s390x";
66
@MACRO_NAME: is_s390x_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `s390x` feature is enabled.
8+
/// Check for the presence of a CPU feature at runtime.
9+
///
10+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
11+
/// the macro expands to `true`.
912
#[unstable(feature = "stdarch_s390x_feature_detection", issue = "135413")]
1013
@FEATURE: #[unstable(feature = "stdarch_s390x_feature_detection", issue = "135413")] concurrent_functions: "concurrent-functions";
1114
/// s390x concurrent-functions facility

library/std_detect/src/detect/arch/x86.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ features! {
2020
@CFG: any(target_arch = "x86", target_arch = "x86_64");
2121
@MACRO_NAME: is_x86_feature_detected;
2222
@MACRO_ATTRS:
23-
/// A macro to test at *runtime* whether a CPU feature is available on
24-
/// x86/x86-64 platforms.
23+
/// Check for the presence of a CPU feature at runtime.
2524
///
26-
/// This macro is provided in the standard library and will detect at runtime
27-
/// whether the specified CPU feature is detected. This does **not** resolve at
28-
/// compile time unless the specified feature is already enabled for the entire
29-
/// crate. Runtime detection currently relies mostly on the `cpuid` instruction.
25+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
26+
/// the macro expands to `true`.
27+
///
28+
/// Runtime detection currently relies mostly on the `cpuid` instruction.
3029
///
3130
/// This macro only takes one argument which is a string literal of the feature
3231
/// being tested for. The feature names supported are the lowercase versions of

0 commit comments

Comments
 (0)