Skip to content

Commit 0c4890a

Browse files
authored
Emit the full is_{arch}_feature_detected! macro on all arches when building docs (#1276)
1 parent f4c5507 commit 0c4890a

File tree

1 file changed

+45
-1
lines changed
  • crates/std_detect/src/detect

1 file changed

+45
-1
lines changed

crates/std_detect/src/detect/mod.rs

+45-1
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,58 @@
1919
2020
use cfg_if::cfg_if;
2121

22+
#[cfg(not(doc))]
2223
#[macro_use]
2324
mod error_macros;
2425

2526
#[macro_use]
2627
mod macros;
2728

2829
cfg_if! {
29-
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
30+
if #[cfg(doc)] {
31+
// When building docs, emit the full macro for all supported arches.
32+
#[allow(dead_code)]
33+
mod arch {
34+
#[path = "x86.rs"]
35+
#[macro_use]
36+
mod x86;
37+
#[path = "arm.rs"]
38+
#[macro_use]
39+
mod arm;
40+
#[path = "aarch64.rs"]
41+
#[macro_use]
42+
mod aarch64;
43+
#[path = "riscv.rs"]
44+
#[macro_use]
45+
mod riscv;
46+
#[path = "powerpc.rs"]
47+
#[macro_use]
48+
mod powerpc;
49+
#[path = "powerpc64.rs"]
50+
#[macro_use]
51+
mod powerpc64;
52+
#[path = "mips.rs"]
53+
#[macro_use]
54+
mod mips;
55+
#[path = "mips64.rs"]
56+
#[macro_use]
57+
mod mips64;
58+
59+
#[doc(hidden)]
60+
pub(crate) enum Feature {
61+
Null
62+
}
63+
#[doc(hidden)]
64+
pub mod __is_feature_detected {}
65+
66+
impl Feature {
67+
#[doc(hidden)]
68+
pub(crate) fn from_str(_s: &str) -> Result<Feature, ()> { Err(()) }
69+
#[doc(hidden)]
70+
pub(crate) fn to_str(self) -> &'static str { "" }
71+
}
72+
}
73+
} else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
3074
#[path = "arch/x86.rs"]
3175
#[macro_use]
3276
mod arch;

0 commit comments

Comments
 (0)