|
5 | 5 |
|
6 | 6 | pub mod raw;
|
7 | 7 |
|
8 |
| -cfg_if::cfg_if! { |
9 |
| - if #[cfg(all(doc, not(any(target_os = "hermit", |
10 |
| - all(target_arch = "wasm32", not(target_os = "wasi")), |
11 |
| - all(target_vendor = "fortanix", target_env = "sgx")))))]{ |
12 |
| - // When documenting std we want to show the `unix`, `windows`, `linux` and `wasi` |
13 |
| - // modules as these are the "main modules" that are used across platforms, |
14 |
| - // so these modules are enabled when `cfg(doc)` is set. |
15 |
| - // This should help show platform-specific functionality in a hopefully cross-platform |
16 |
| - // way in the documentation. |
17 |
| - |
18 |
| - pub mod unix; |
19 |
| - |
20 |
| - pub mod linux; |
21 |
| - |
22 |
| - pub mod wasi; |
23 |
| - |
24 |
| - pub mod windows; |
25 |
| - } else if #[cfg(doc)] { |
26 |
| - // On certain platforms right now the "main modules" modules that are |
27 |
| - // documented don't compile (missing things in `libc` which is empty), |
28 |
| - // so just omit them with an empty module. |
29 |
| - |
30 |
| - #[unstable(issue = "none", feature = "std_internals")] |
31 |
| - pub mod unix {} |
32 |
| - |
33 |
| - #[unstable(issue = "none", feature = "std_internals")] |
34 |
| - pub mod linux {} |
35 |
| - |
36 |
| - #[unstable(issue = "none", feature = "std_internals")] |
37 |
| - pub mod wasi {} |
38 |
| - |
39 |
| - #[unstable(issue = "none", feature = "std_internals")] |
40 |
| - pub mod windows {} |
41 |
| - } else { |
42 |
| - // If we're not documenting std then we only expose modules appropriate for the |
43 |
| - // current platform. |
44 |
| - |
45 |
| - #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] |
46 |
| - pub mod fortanix_sgx; |
47 |
| - |
48 |
| - #[cfg(target_os = "hermit")] |
49 |
| - mod hermit; |
50 |
| - #[cfg(target_os = "hermit")] |
51 |
| - pub use hermit as unix; |
52 |
| - |
53 |
| - #[cfg(unix)] |
54 |
| - pub mod unix; |
55 |
| - #[cfg(target_os = "android")] |
56 |
| - pub mod android; |
57 |
| - #[cfg(target_os = "dragonfly")] |
58 |
| - pub mod dragonfly; |
59 |
| - #[cfg(target_os = "emscripten")] |
60 |
| - pub mod emscripten; |
61 |
| - #[cfg(target_os = "freebsd")] |
62 |
| - pub mod freebsd; |
63 |
| - #[cfg(target_os = "fuchsia")] |
64 |
| - pub mod fuchsia; |
65 |
| - #[cfg(target_os = "haiku")] |
66 |
| - pub mod haiku; |
67 |
| - #[cfg(target_os = "illumos")] |
68 |
| - pub mod illumos; |
69 |
| - #[cfg(target_os = "ios")] |
70 |
| - pub mod ios; |
71 |
| - #[cfg(target_os = "l4re")] |
72 |
| - pub mod linux; |
73 |
| - #[cfg(target_os = "linux")] |
74 |
| - pub mod linux; |
75 |
| - #[cfg(target_os = "macos")] |
76 |
| - pub mod macos; |
77 |
| - #[cfg(target_os = "netbsd")] |
78 |
| - pub mod netbsd; |
79 |
| - #[cfg(target_os = "openbsd")] |
80 |
| - pub mod openbsd; |
81 |
| - #[cfg(target_os = "redox")] |
82 |
| - pub mod redox; |
83 |
| - #[cfg(target_os = "solaris")] |
84 |
| - pub mod solaris; |
85 |
| - |
86 |
| - #[cfg(target_os = "vxworks")] |
87 |
| - pub mod vxworks; |
88 |
| - |
89 |
| - #[cfg(target_os = "wasi")] |
90 |
| - pub mod wasi; |
91 |
| - |
92 |
| - #[cfg(windows)] |
93 |
| - pub mod windows; |
94 |
| - } |
| 8 | +// The code below could be written clearer using `cfg_if!`. However, the items below are |
| 9 | +// publicly exported by `std` and external tools can have trouble analysing them because of the use |
| 10 | +// of a macro that is not vendored by Rust and included in the toolchain. |
| 11 | +// See https://github.com/rust-analyzer/rust-analyzer/issues/6038. |
| 12 | + |
| 13 | +#[cfg(all( |
| 14 | + doc, |
| 15 | + not(any( |
| 16 | + target_os = "hermit", |
| 17 | + all(target_arch = "wasm32", not(target_os = "wasi")), |
| 18 | + all(target_vendor = "fortanix", target_env = "sgx") |
| 19 | + )) |
| 20 | +))] |
| 21 | +#[path = "."] |
| 22 | +mod doc { |
| 23 | + // When documenting std we want to show the `unix`, `windows`, `linux` and `wasi` |
| 24 | + // modules as these are the "main modules" that are used across platforms, |
| 25 | + // so these modules are enabled when `cfg(doc)` is set. |
| 26 | + // This should help show platform-specific functionality in a hopefully cross-platform |
| 27 | + // way in the documentation. |
| 28 | + |
| 29 | + pub mod unix; |
| 30 | + |
| 31 | + pub mod linux; |
| 32 | + |
| 33 | + pub mod wasi; |
| 34 | + |
| 35 | + pub mod windows; |
95 | 36 | }
|
| 37 | +#[cfg(all( |
| 38 | + doc, |
| 39 | + any( |
| 40 | + target_os = "hermit", |
| 41 | + all(target_arch = "wasm32", not(target_os = "wasi")), |
| 42 | + all(target_vendor = "fortanix", target_env = "sgx") |
| 43 | + ) |
| 44 | +))] |
| 45 | +mod doc { |
| 46 | + // On certain platforms right now the "main modules" modules that are |
| 47 | + // documented don't compile (missing things in `libc` which is empty), |
| 48 | + // so just omit them with an empty module. |
| 49 | + |
| 50 | + #[unstable(issue = "none", feature = "std_internals")] |
| 51 | + pub mod unix {} |
| 52 | + |
| 53 | + #[unstable(issue = "none", feature = "std_internals")] |
| 54 | + pub mod linux {} |
| 55 | + |
| 56 | + #[unstable(issue = "none", feature = "std_internals")] |
| 57 | + pub mod wasi {} |
| 58 | + |
| 59 | + #[unstable(issue = "none", feature = "std_internals")] |
| 60 | + pub mod windows {} |
| 61 | +} |
| 62 | +#[cfg(doc)] |
| 63 | +#[stable(feature = "os", since = "1.0.0")] |
| 64 | +pub use doc::*; |
| 65 | + |
| 66 | +#[cfg(not(doc))] |
| 67 | +#[path = "."] |
| 68 | +mod imp { |
| 69 | + // If we're not documenting std then we only expose modules appropriate for the |
| 70 | + // current platform. |
| 71 | + |
| 72 | + #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] |
| 73 | + pub mod fortanix_sgx; |
| 74 | + |
| 75 | + #[cfg(target_os = "hermit")] |
| 76 | + #[path = "hermit/mod.rs"] |
| 77 | + pub mod unix; |
| 78 | + |
| 79 | + #[cfg(target_os = "android")] |
| 80 | + pub mod android; |
| 81 | + #[cfg(target_os = "dragonfly")] |
| 82 | + pub mod dragonfly; |
| 83 | + #[cfg(target_os = "emscripten")] |
| 84 | + pub mod emscripten; |
| 85 | + #[cfg(target_os = "freebsd")] |
| 86 | + pub mod freebsd; |
| 87 | + #[cfg(target_os = "fuchsia")] |
| 88 | + pub mod fuchsia; |
| 89 | + #[cfg(target_os = "haiku")] |
| 90 | + pub mod haiku; |
| 91 | + #[cfg(target_os = "illumos")] |
| 92 | + pub mod illumos; |
| 93 | + #[cfg(target_os = "ios")] |
| 94 | + pub mod ios; |
| 95 | + #[cfg(target_os = "l4re")] |
| 96 | + pub mod linux; |
| 97 | + #[cfg(target_os = "linux")] |
| 98 | + pub mod linux; |
| 99 | + #[cfg(target_os = "macos")] |
| 100 | + pub mod macos; |
| 101 | + #[cfg(target_os = "netbsd")] |
| 102 | + pub mod netbsd; |
| 103 | + #[cfg(target_os = "openbsd")] |
| 104 | + pub mod openbsd; |
| 105 | + #[cfg(target_os = "redox")] |
| 106 | + pub mod redox; |
| 107 | + #[cfg(target_os = "solaris")] |
| 108 | + pub mod solaris; |
| 109 | + #[cfg(unix)] |
| 110 | + pub mod unix; |
| 111 | + |
| 112 | + #[cfg(target_os = "vxworks")] |
| 113 | + pub mod vxworks; |
| 114 | + |
| 115 | + #[cfg(target_os = "wasi")] |
| 116 | + pub mod wasi; |
| 117 | + |
| 118 | + #[cfg(windows)] |
| 119 | + pub mod windows; |
| 120 | +} |
| 121 | +#[cfg(not(doc))] |
| 122 | +#[stable(feature = "os", since = "1.0.0")] |
| 123 | +pub use imp::*; |
0 commit comments