Skip to content

Commit 1a4a700

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 9725c4b commit 1a4a700

File tree

10 files changed

+53
-16
lines changed

10 files changed

+53
-16
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+
/// This macro tests whether an `aarch64` feature is enabled on aarch64 platforms.
9+
///
10+
/// If the feature has been statically enabled for the whole crate (e.g. with
11+
/// `-Ctarget-feature`), this macro expands to `true`. Otherwise it performs a
12+
/// runtime check.
1013
///
1114
/// This macro takes one argument which is a string literal of the feature being tested for.
1215
/// The feature names are mostly taken from their FEAT_* definitions in the [ARM Architecture
1316
/// Reference Manual][docs].
1417
///
18+
/// Currently most features are only supported on linux-based platforms.
19+
///
1520
/// ## Supported arguments
1621
///
1722
/// * `"aes"` - FEAT_AES & FEAT_PMULL

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ features! {
55
@CFG: target_arch = "arm";
66
@MACRO_NAME: is_arm_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `arm` feature is enabled.
8+
/// Checks whether an `arm` feature is enabled.
9+
///
10+
/// If the feature has been statically enabled for the whole crate (e.g. with
11+
/// `-Ctarget-feature`), this macro expands to `true`. Otherwise it performs a
12+
/// runtime check.
913
#[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")]
1014
@NO_RUNTIME_DETECTION: "v7";
1115
@NO_RUNTIME_DETECTION: "vfp2";

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ 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+
/// Checks whether a `loongarch` feature is enabled.
9+
///
10+
/// If the feature has been statically enabled for the whole crate (e.g. with
11+
/// `-Ctarget-feature`), this macro expands to `true`. Otherwise it performs a
12+
/// runtime check.
13+
///
914
/// Supported arguments are:
1015
///
1116
/// * `"32s"`

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ features! {
55
@CFG: target_arch = "mips";
66
@MACRO_NAME: is_mips_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `mips` feature is enabled.
8+
/// Checks whether a `mips` feature is enabled.
9+
///
10+
/// If the feature has been statically enabled for the whole crate (e.g. with
11+
/// `-Ctarget-feature`), this macro expands to `true`. Otherwise it performs a
12+
/// runtime check.
913
#[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")]
1014
@FEATURE: #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] msa: "msa";
1115
/// MIPS SIMD Architecture (MSA)

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ features! {
55
@CFG: target_arch = "mips64";
66
@MACRO_NAME: is_mips64_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `mips64` feature is enabled.
8+
/// Checks whether a `mips64` feature is enabled.
9+
///
10+
/// If the feature has been statically enabled for the whole crate (e.g. with
11+
/// `-Ctarget-feature`), this macro expands to `true`. Otherwise it performs a
12+
/// runtime check.
913
#[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")]
1014
@FEATURE: #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] msa: "msa";
1115
/// MIPS SIMD Architecture (MSA)

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ features! {
55
@CFG: target_arch = "powerpc";
66
@MACRO_NAME: is_powerpc_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `powerpc` feature is enabled.
8+
/// Checks a if `powerpc` feature is enabled.
9+
///
10+
/// If the feature has been statically enabled for the whole crate (e.g. with
11+
/// `-Ctarget-feature`), this macro expands to `true`. Otherwise it performs a
12+
/// runtime check.
913
#[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")]
1014
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] altivec: "altivec";
1115
/// Altivec

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ features! {
55
@CFG: target_arch = "powerpc64";
66
@MACRO_NAME: is_powerpc64_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `powerpc` feature is enabled.
8+
/// Checks whether a `powerpc` feature is enabled.
9+
///
10+
/// If the feature has been statically enabled for the whole crate (e.g. with
11+
/// `-Ctarget-feature`), this macro expands to `true`. Otherwise it performs a
12+
/// runtime check.
913
#[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")]
1014
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] altivec: "altivec";
1115
/// Altivec

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ 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+
/// A macro to test whether instruction sets are available on RISC-V platforms.
9+
///
10+
/// If the feature has been statically enabled for the whole crate (e.g. with
11+
/// `-Ctarget-feature`), this macro expands to `true`. Otherwise it performs a
12+
/// runtime check.
1013
///
1114
/// RISC-V standard defined the base sets and the extension sets.
1215
/// The base sets are RV32I, RV64I, RV32E or RV128I. Any RISC-V platform

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ features! {
55
@CFG: target_arch = "s390x";
66
@MACRO_NAME: is_s390x_feature_detected;
77
@MACRO_ATTRS:
8-
/// Checks if `s390x` feature is enabled.
8+
/// Checks whether a `s390x` feature is enabled.
9+
///
10+
/// If the feature has been statically enabled for the whole crate (e.g. with
11+
/// `-Ctarget-feature`), this macro expands to `true`. Otherwise it performs a
12+
/// runtime check.
913
#[unstable(feature = "stdarch_s390x_feature_detection", issue = "135413")]
1014
@FEATURE: #[unstable(feature = "stdarch_s390x_feature_detection", issue = "135413")] concurrent_functions: "concurrent-functions";
1115
/// s390x concurrent-functions facility

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ 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
23+
/// A macro to test at whether a CPU feature is available on
2424
/// x86/x86-64 platforms.
2525
///
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.
26+
/// If the feature has been statically enabled for the whole crate (e.g. with
27+
/// `-Ctarget-feature`), this macro expands to `true`. Otherwise it performs a
28+
/// runtime check. Runtime detection currently relies mostly on the `cpuid`
29+
/// instruction.
3030
///
3131
/// This macro only takes one argument which is a string literal of the feature
3232
/// being tested for. The feature names supported are the lowercase versions of

0 commit comments

Comments
 (0)