Skip to content

Commit f064ad7

Browse files
Rollup merge of rust-lang#88619 - GuillaumeGomez:simplify-std-os-reexports, r=Amanieu
Remove `cfg(doc)` from std::os module reexports to fix rustdoc linking issues Fixes rust-lang#88304. I tested it based on rust-lang#88292. Not sure if it's the best approach, but at least it makes thing a bit simpler. cc ``@jyn514``
2 parents 24fed97 + 88d5aa6 commit f064ad7

File tree

1 file changed

+103
-99
lines changed

1 file changed

+103
-99
lines changed

library/std/src/os/mod.rs

+103-99
Original file line numberDiff line numberDiff line change
@@ -10,117 +10,121 @@ 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+
// 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+
// Unix, linux, wasi and windows are handled a bit differently.
1318
#[cfg(all(
1419
doc,
15-
not(any(
20+
any(
1621
all(target_arch = "wasm32", not(target_os = "wasi")),
1722
all(target_vendor = "fortanix", target_env = "sgx")
18-
))
23+
)
1924
))]
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-
}
25+
#[unstable(issue = "none", feature = "std_internals")]
26+
pub mod unix {}
3627
#[cfg(all(
3728
doc,
3829
any(
3930
all(target_arch = "wasm32", not(target_os = "wasi")),
4031
all(target_vendor = "fortanix", target_env = "sgx")
4132
)
4233
))]
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 {}
59-
}
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;
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 = "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::*;
34+
#[unstable(issue = "none", feature = "std_internals")]
35+
pub mod linux {}
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+
#[unstable(issue = "none", feature = "std_internals")]
44+
pub mod wasi {}
45+
#[cfg(all(
46+
doc,
47+
any(
48+
all(target_arch = "wasm32", not(target_os = "wasi")),
49+
all(target_vendor = "fortanix", target_env = "sgx")
50+
)
51+
))]
52+
#[unstable(issue = "none", feature = "std_internals")]
53+
pub mod windows {}
54+
55+
// unix
56+
#[cfg(not(any(
57+
all(target_arch = "wasm32", not(target_os = "wasi")),
58+
all(target_vendor = "fortanix", target_env = "sgx")
59+
)))]
60+
#[cfg(all(not(doc), target_os = "hermit"))]
61+
#[path = "hermit/mod.rs"]
62+
pub mod unix;
63+
#[cfg(not(any(
64+
all(target_arch = "wasm32", not(target_os = "wasi")),
65+
all(target_vendor = "fortanix", target_env = "sgx")
66+
)))]
67+
#[cfg(any(unix, doc))]
68+
pub mod unix;
69+
70+
// linux
71+
#[cfg(not(any(
72+
all(target_arch = "wasm32", not(target_os = "wasi")),
73+
all(target_vendor = "fortanix", target_env = "sgx")
74+
)))]
75+
#[cfg(any(target_os = "linux", target_os = "l4re", doc))]
76+
pub mod linux;
77+
78+
// wasi
79+
#[cfg(not(any(
80+
all(target_arch = "wasm32", not(target_os = "wasi")),
81+
all(target_vendor = "fortanix", target_env = "sgx")
82+
)))]
83+
#[cfg(any(target_os = "wasi", doc))]
84+
pub mod wasi;
85+
86+
// windows
87+
#[cfg(not(any(
88+
all(target_arch = "wasm32", not(target_os = "wasi")),
89+
all(target_vendor = "fortanix", target_env = "sgx")
90+
)))]
91+
#[cfg(any(windows, doc))]
92+
pub mod windows;
93+
94+
// Others.
95+
#[cfg(target_os = "android")]
96+
pub mod android;
97+
#[cfg(target_os = "dragonfly")]
98+
pub mod dragonfly;
99+
#[cfg(target_os = "emscripten")]
100+
pub mod emscripten;
101+
#[cfg(target_os = "espidf")]
102+
pub mod espidf;
103+
#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
104+
pub mod fortanix_sgx;
105+
#[cfg(target_os = "freebsd")]
106+
pub mod freebsd;
107+
#[cfg(target_os = "fuchsia")]
108+
pub mod fuchsia;
109+
#[cfg(target_os = "haiku")]
110+
pub mod haiku;
111+
#[cfg(target_os = "illumos")]
112+
pub mod illumos;
113+
#[cfg(target_os = "ios")]
114+
pub mod ios;
115+
#[cfg(target_os = "macos")]
116+
pub mod macos;
117+
#[cfg(target_os = "netbsd")]
118+
pub mod netbsd;
119+
#[cfg(target_os = "openbsd")]
120+
pub mod openbsd;
121+
#[cfg(target_os = "redox")]
122+
pub mod redox;
123+
#[cfg(target_os = "solaris")]
124+
pub mod solaris;
125+
126+
#[cfg(target_os = "vxworks")]
127+
pub mod vxworks;
124128

125129
#[cfg(any(unix, target_os = "wasi", doc))]
126130
mod fd;

0 commit comments

Comments
 (0)