Skip to content

Commit 7bc5016

Browse files
Avoid cfg_if in std::os
1 parent 15598a8 commit 7bc5016

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

library/std/src/os/mod.rs

+27-27
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,40 @@
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.
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
812

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
13+
#[cfg(doc)]
14+
#[stable(feature = "rust1", since = "1.0.0")]
15+
pub use crate::sys::unix_ext as unix;
1316

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

17-
#[stable(feature = "rust1", since = "1.0.0")]
18-
pub use crate::sys::windows_ext as windows;
21+
#[cfg(doc)]
22+
#[doc(cfg(target_os = "linux"))]
23+
pub mod linux;
1924

20-
#[doc(cfg(target_os = "linux"))]
21-
pub mod linux;
22-
} else {
25+
// If we're not documenting libstd then we just expose the main modules as we otherwise would.
2326

24-
// If we're not documenting libstd then we just expose the main modules
25-
// as we otherwise would.
27+
#[cfg(not(doc))]
28+
#[cfg(any(target_os = "redox", unix, target_os = "vxworks", target_os = "hermit"))]
29+
#[stable(feature = "rust1", since = "1.0.0")]
30+
pub use crate::sys::ext as unix;
2631

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;
32+
#[cfg(not(doc))]
33+
#[cfg(windows)]
34+
#[stable(feature = "rust1", since = "1.0.0")]
35+
pub use crate::sys::ext as windows;
3036

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-
}
37+
#[cfg(not(doc))]
38+
#[cfg(any(target_os = "linux", target_os = "l4re"))]
39+
pub mod linux;
4040

4141
#[cfg(target_os = "android")]
4242
pub mod android;

0 commit comments

Comments
 (0)