about summary refs log tree commit diff
path: root/library/std/src/os
diff options
context:
space:
mode:
authorChristiaan Dirkx <christiaan@dirkx.email>2021-03-04 14:03:26 +0100
committerChristiaan Dirkx <christiaan@dirkx.email>2021-05-03 16:56:20 +0200
commit0e2cd33db84a4787391989c69ed3ce70ce8c07ec (patch)
treee15cd5bfea05ba74f138f4eac428a4b5bd4d8087 /library/std/src/os
parentc825bc431ee5b815847b9bab693c59c43986fc4b (diff)
downloadrust-0e2cd33db84a4787391989c69ed3ce70ce8c07ec.tar.gz
rust-0e2cd33db84a4787391989c69ed3ce70ce8c07ec.zip
Cleanup `std::os`
Diffstat (limited to 'library/std/src/os')
-rw-r--r--library/std/src/os/linux/mod.rs1
-rw-r--r--library/std/src/os/linux/raw.rs1
-rw-r--r--library/std/src/os/mod.rs163
-rw-r--r--library/std/src/os/redox/raw.rs1
4 files changed, 90 insertions, 76 deletions
diff --git a/library/std/src/os/linux/mod.rs b/library/std/src/os/linux/mod.rs
index f179a524336..94438defc22 100644
--- a/library/std/src/os/linux/mod.rs
+++ b/library/std/src/os/linux/mod.rs
@@ -1,6 +1,7 @@
 //! Linux-specific definitions.
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
+#![doc(cfg(target_os = "linux"))]
 
 pub mod fs;
 pub mod raw;
diff --git a/library/std/src/os/linux/raw.rs b/library/std/src/os/linux/raw.rs
index 525102212c4..5b68a7e1262 100644
--- a/library/std/src/os/linux/raw.rs
+++ b/library/std/src/os/linux/raw.rs
@@ -9,7 +9,6 @@
               definitions"
 )]
 #![allow(deprecated)]
-#![allow(missing_debug_implementations)]
 
 use crate::os::raw::c_ulong;
 
diff --git a/library/std/src/os/mod.rs b/library/std/src/os/mod.rs
index b95511e43d8..7e333e2b778 100644
--- a/library/std/src/os/mod.rs
+++ b/library/std/src/os/mod.rs
@@ -3,78 +3,93 @@
 #![stable(feature = "os", since = "1.0.0")]
 #![allow(missing_docs, nonstandard_style, missing_debug_implementations)]
 
-// When documenting libstd we want to show unix/windows/linux/wasi modules as these are the "main
-// modules" that are used across platforms, so all modules are enabled when `cfg(doc)` is set.
-// This should help show platform-specific functionality in a hopefully cross-platform way in the
-// documentation.
-// Note that we deliberately avoid `cfg_if!` here to work around a rust-analyzer bug that would make
-// `std::os` submodules unusable: https://github.com/rust-analyzer/rust-analyzer/issues/6038
-
-#[cfg(doc)]
-#[stable(feature = "rust1", since = "1.0.0")]
-pub use crate::sys::unix_ext as unix;
-
-#[cfg(doc)]
-#[stable(feature = "rust1", since = "1.0.0")]
-pub use crate::sys::windows_ext as windows;
-
-#[cfg(doc)]
-#[doc(cfg(target_os = "linux"))]
-pub mod linux;
-
-#[cfg(doc)]
-#[stable(feature = "wasi_ext_doc", since = "1.35.0")]
-pub use crate::sys::wasi_ext as wasi;
-
-// If we're not documenting libstd then we just expose the main modules as we otherwise would.
-
-#[cfg(not(doc))]
-#[cfg(any(unix, target_os = "hermit"))]
-#[stable(feature = "rust1", since = "1.0.0")]
-pub use crate::sys::ext as unix;
-
-#[cfg(not(doc))]
-#[cfg(windows)]
-#[stable(feature = "rust1", since = "1.0.0")]
-pub use crate::sys::ext as windows;
-
-#[cfg(not(doc))]
-#[cfg(any(target_os = "linux", target_os = "l4re"))]
-pub mod linux;
-
-#[cfg(not(doc))]
-#[cfg(target_os = "wasi")]
-pub mod wasi;
-
-#[cfg(target_os = "android")]
-pub mod android;
-#[cfg(target_os = "dragonfly")]
-pub mod dragonfly;
-#[cfg(target_os = "emscripten")]
-pub mod emscripten;
-#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
-pub mod fortanix_sgx;
-#[cfg(target_os = "freebsd")]
-pub mod freebsd;
-#[cfg(target_os = "fuchsia")]
-pub mod fuchsia;
-#[cfg(target_os = "haiku")]
-pub mod haiku;
-#[cfg(target_os = "illumos")]
-pub mod illumos;
-#[cfg(target_os = "ios")]
-pub mod ios;
-#[cfg(target_os = "macos")]
-pub mod macos;
-#[cfg(target_os = "netbsd")]
-pub mod netbsd;
-#[cfg(target_os = "openbsd")]
-pub mod openbsd;
-#[cfg(target_os = "redox")]
-pub mod redox;
-#[cfg(target_os = "solaris")]
-pub mod solaris;
-#[cfg(target_os = "vxworks")]
-pub mod vxworks;
-
 pub mod raw;
+
+cfg_if::cfg_if! {
+    if #[cfg(all(doc, not(any(target_os = "hermit",
+                        all(target_arch = "wasm32", not(target_os = "wasi")),
+                        all(target_vendor = "fortanix", target_env = "sgx")))))]{
+        // When documenting std we want to show the `unix`, `windows`, `linux` and `wasi`
+        // modules as these are the "main modules" that are used across platforms,
+        // so these modules are enabled when `cfg(doc)` is set.
+        // This should help show platform-specific functionality in a hopefully cross-platform
+        // way in the documentation.
+
+        #[stable(feature = "rust1", since = "1.0.0")]
+        pub use crate::sys::unix_ext as unix;
+
+        pub mod linux;
+
+        #[stable(feature = "wasi_ext_doc", since = "1.35.0")]
+        pub use crate::sys::wasi_ext as wasi;
+
+        #[stable(feature = "rust1", since = "1.0.0")]
+        pub use crate::sys::windows_ext as windows;
+    } else if #[cfg(doc)] {
+        // On certain platforms right now the "main modules" modules that are
+        // documented don't compile (missing things in `libc` which is empty),
+        // so just omit them with an empty module.
+
+        #[unstable(issue = "none", feature = "std_internals")]
+        pub mod unix {}
+
+        #[unstable(issue = "none", feature = "std_internals")]
+        pub mod linux {}
+
+        #[unstable(issue = "none", feature = "std_internals")]
+        pub mod wasi {}
+
+        #[unstable(issue = "none", feature = "std_internals")]
+        pub mod windows {}
+    } else {
+        // If we're not documenting std then we only expose modules appropriate for the
+        // current platform.
+
+        #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
+        pub mod fortanix_sgx;
+
+        #[cfg(any(unix, target_os = "hermit"))]
+        #[stable(feature = "rust1", since = "1.0.0")]
+        pub use crate::sys::ext as unix;
+        #[cfg(target_os = "android")]
+        pub mod android;
+        #[cfg(target_os = "dragonfly")]
+        pub mod dragonfly;
+        #[cfg(target_os = "emscripten")]
+        pub mod emscripten;
+        #[cfg(target_os = "freebsd")]
+        pub mod freebsd;
+        #[cfg(target_os = "fuchsia")]
+        pub mod fuchsia;
+        #[cfg(target_os = "haiku")]
+        pub mod haiku;
+        #[cfg(target_os = "illumos")]
+        pub mod illumos;
+        #[cfg(target_os = "ios")]
+        pub mod ios;
+        #[cfg(target_os = "l4re")]
+        pub mod linux;
+        #[cfg(target_os = "linux")]
+        pub mod linux;
+        #[cfg(target_os = "macos")]
+        pub mod macos;
+        #[cfg(target_os = "netbsd")]
+        pub mod netbsd;
+        #[cfg(target_os = "openbsd")]
+        pub mod openbsd;
+        #[cfg(target_os = "redox")]
+        pub mod redox;
+        #[cfg(target_os = "solaris")]
+        pub mod solaris;
+
+        #[cfg(target_os = "vxworks")]
+        pub mod vxworks;
+
+        #[cfg(target_os = "wasi")]
+        pub mod wasi;
+
+        #[cfg(windows)]
+        #[stable(feature = "rust1", since = "1.0.0")]
+        pub use crate::sys::ext as windows;
+    }
+}
diff --git a/library/std/src/os/redox/raw.rs b/library/std/src/os/redox/raw.rs
index abe6dfc6b0c..9a6b99684c5 100644
--- a/library/std/src/os/redox/raw.rs
+++ b/library/std/src/os/redox/raw.rs
@@ -9,7 +9,6 @@
               definitions"
 )]
 #![allow(deprecated)]
-#![allow(missing_debug_implementations)]
 
 use crate::os::raw::{c_char, c_int, c_long, c_ulong, c_void};