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