Skip to content

Commit 4bf910b

Browse files
Avoid cfg_if in std::os
1 parent 07194ff commit 4bf910b

File tree

1 file changed

+20
-29
lines changed

1 file changed

+20
-29
lines changed

library/std/src/os/mod.rs

+20-29
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,31 @@
33
#![stable(feature = "os", since = "1.0.0")]
44
#![allow(missing_docs, nonstandard_style, missing_debug_implementations)]
55

6-
cfg_if::cfg_if! {
7-
if #[cfg(doc)] {
6+
// When documenting libstd we want to show unix/windows/linux 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.
810

9-
// When documenting libstd we want to show unix/windows/linux modules as
10-
// these are the "main modules" that are used across platforms. This
11-
// should help show platform-specific functionality in a hopefully
12-
// cross-platform way in the documentation
11+
#[cfg(doc)]
12+
#[stable(feature = "rust1", since = "1.0.0")]
13+
pub use crate::sys::unix_ext as unix;
1314

14-
#[stable(feature = "rust1", since = "1.0.0")]
15-
pub use crate::sys::unix_ext as unix;
15+
#[cfg(doc)]
16+
#[stable(feature = "rust1", since = "1.0.0")]
17+
pub use crate::sys::windows_ext as windows;
1618

17-
#[stable(feature = "rust1", since = "1.0.0")]
18-
pub use crate::sys::windows_ext as windows;
19+
#[cfg(not(doc))]
20+
#[cfg(any(target_os = "redox", unix, target_os = "vxworks", target_os = "hermit"))]
21+
#[stable(feature = "rust1", since = "1.0.0")]
22+
pub use crate::sys::ext as unix;
1923

20-
#[doc(cfg(target_os = "linux"))]
21-
pub mod linux;
22-
} else {
24+
#[cfg(not(doc))]
25+
#[cfg(windows)]
26+
#[stable(feature = "rust1", since = "1.0.0")]
27+
pub use crate::sys::ext as windows;
2328

24-
// If we're not documenting libstd then we just expose the main modules
25-
// as we otherwise would.
26-
27-
#[cfg(any(target_os = "redox", unix, target_os = "vxworks", target_os = "hermit"))]
28-
#[stable(feature = "rust1", since = "1.0.0")]
29-
pub use crate::sys::ext as unix;
30-
31-
#[cfg(windows)]
32-
#[stable(feature = "rust1", since = "1.0.0")]
33-
pub use crate::sys::ext as windows;
34-
35-
#[cfg(any(target_os = "linux", target_os = "l4re"))]
36-
pub mod linux;
37-
38-
}
39-
}
29+
#[cfg(any(doc, target_os = "linux", target_os = "l4re"))]
30+
pub mod linux;
4031

4132
#[cfg(target_os = "android")]
4233
pub mod android;

0 commit comments

Comments
 (0)