@@ -10,117 +10,82 @@ pub mod raw;
1010// of a macro that is not vendored by Rust and included in the toolchain.
1111// See https://github.com/rust-analyzer/rust-analyzer/issues/6038.
1212
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.
27-
28- pub mod unix;
29-
30- pub mod linux;
31-
32- pub mod wasi;
33-
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.
47-
48- #[ unstable( issue = "none" , feature = "std_internals" ) ]
49- pub mod unix { }
50-
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 { }
13+ // On certain platforms right now the "main modules" modules that are
14+ // documented don't compile (missing things in `libc` which is empty),
15+ // so just omit them with an empty module and add the "unstable" attribute.
16+
17+ #[ cfg( all( target_vendor = "fortanix" , target_env = "sgx" ) ) ]
18+ pub mod fortanix_sgx;
19+
20+ // Unix, linux, wasi and windows are handled a bit differently.
21+ cfg_if:: cfg_if! {
22+ if #[ cfg( all(
23+ doc,
24+ any(
25+ all( target_arch = "wasm32" , not( target_os = "wasi" ) ) ,
26+ all( target_vendor = "fortanix" , target_env = "sgx" )
27+ )
28+ ) ) ]
29+ {
30+ #[ unstable( issue = "none" , feature = "std_internals" ) ]
31+ pub mod unix { }
32+ #[ unstable( issue = "none" , feature = "std_internals" ) ]
33+ pub mod linux { }
34+ #[ unstable( issue = "none" , feature = "std_internals" ) ]
35+ pub mod wasi { }
36+ #[ unstable( issue = "none" , feature = "std_internals" ) ]
37+ pub mod windows { }
38+ } else {
39+ #[ cfg( target_os = "hermit" ) ]
40+ #[ path = "hermit/mod.rs" ]
41+ pub mod unix;
42+
43+ #[ cfg( any( unix, doc) ) ]
44+ pub mod unix;
45+
46+ #[ cfg( any( target_os = "linux" , target_os = "l4re" , doc) ) ]
47+ pub mod linux;
48+
49+ #[ cfg( any( target_os = "wasi" , doc) ) ]
50+ pub mod wasi;
51+
52+ #[ cfg( any( windows, doc) ) ]
53+ pub mod windows;
54+ }
5955}
60- #[ cfg( doc) ]
61- #[ stable( feature = "os" , since = "1.0.0" ) ]
62- pub use doc:: * ;
63-
64- #[ cfg( not( doc) ) ]
65- #[ path = "." ]
66- mod imp {
67- // If we're not documenting std then we only expose modules appropriate for the
68- // current platform.
69-
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;
7656
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 = "espidf" ) ]
84- pub mod espidf;
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:: * ;
57+ // Others.
58+ #[ cfg( target_os = "android" ) ]
59+ pub mod android;
60+ #[ cfg( target_os = "dragonfly" ) ]
61+ pub mod dragonfly;
62+ #[ cfg( target_os = "emscripten" ) ]
63+ pub mod emscripten;
64+ #[ cfg( target_os = "espidf" ) ]
65+ pub mod espidf;
66+ #[ cfg( target_os = "freebsd" ) ]
67+ pub mod freebsd;
68+ #[ cfg( target_os = "fuchsia" ) ]
69+ pub mod fuchsia;
70+ #[ cfg( target_os = "haiku" ) ]
71+ pub mod haiku;
72+ #[ cfg( target_os = "illumos" ) ]
73+ pub mod illumos;
74+ #[ cfg( target_os = "ios" ) ]
75+ pub mod ios;
76+ #[ cfg( target_os = "macos" ) ]
77+ pub mod macos;
78+ #[ cfg( target_os = "netbsd" ) ]
79+ pub mod netbsd;
80+ #[ cfg( target_os = "openbsd" ) ]
81+ pub mod openbsd;
82+ #[ cfg( target_os = "redox" ) ]
83+ pub mod redox;
84+ #[ cfg( target_os = "solaris" ) ]
85+ pub mod solaris;
86+
87+ #[ cfg( target_os = "vxworks" ) ]
88+ pub mod vxworks;
12489
12590#[ cfg( any( unix, target_os = "wasi" , doc) ) ]
12691mod fd;
0 commit comments