diff options
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/os/linux/mod.rs | 1 | ||||
| -rw-r--r-- | library/std/src/os/linux/raw.rs | 1 | ||||
| -rw-r--r-- | library/std/src/os/mod.rs | 163 | ||||
| -rw-r--r-- | library/std/src/os/redox/raw.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sys/mod.rs | 58 |
5 files changed, 113 insertions, 111 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}; diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index 2450a7aac5e..33e68d12b0a 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -49,25 +49,22 @@ cfg_if::cfg_if! { } } -// Import essential modules from both platforms when documenting. These are -// then later used in the `std::os` module when documenting, for example, -// Windows when we're compiling for Linux. +// Import essential modules from platforms used in `std::os` when documenting. +// +// Note that on some platforms those modules don't compile +// (missing things in `libc` which is empty), so they are not included in `std::os` and can be +// omitted here as well. #[cfg(doc)] +#[cfg(not(any( + target_os = "hermit", + all(target_arch = "wasm32", not(target_os = "wasi")), + all(target_vendor = "fortanix", target_env = "sgx") +)))] cfg_if::cfg_if! { if #[cfg(unix)] { - // On unix we'll document what's already available #[stable(feature = "rust1", since = "1.0.0")] pub use self::ext as unix_ext; - } else if #[cfg(any(target_os = "hermit", - all(target_arch = "wasm32", not(target_os = "wasi")), - all(target_vendor = "fortanix", target_env = "sgx")))] { - // On non-WASI wasm right now the module below doesn't compile - // (missing things in `libc` which is empty) so just omit everything - // with an empty module - #[unstable(issue = "none", feature = "std_internals")] - #[allow(missing_docs)] - pub mod unix_ext {} } else { #[path = "unix/ext/mod.rs"] pub mod unix_ext; @@ -75,23 +72,20 @@ cfg_if::cfg_if! { } #[cfg(doc)] +#[cfg(not(any( + target_os = "hermit", + all(target_arch = "wasm32", not(target_os = "wasi")), + all(target_vendor = "fortanix", target_env = "sgx") +)))] cfg_if::cfg_if! { if #[cfg(windows)] { - // On windows we'll just be documenting what's already available #[allow(missing_docs)] #[stable(feature = "rust1", since = "1.0.0")] pub use self::ext as windows_ext; - } else if #[cfg(any(target_os = "hermit", - all(target_arch = "wasm32", not(target_os = "wasi")), - all(target_vendor = "fortanix", target_env = "sgx")))] { - // On non-WASI wasm right now the shim below doesn't compile, so - // just omit it - #[unstable(issue = "none", feature = "std_internals")] - #[allow(missing_docs)] - pub mod windows_ext {} } else { - // On all other platforms (aka linux/osx/etc) then pull in a "minimal" + // On non-Windows platforms (aka linux/osx/etc) pull in a "minimal" // amount of windows goop which ends up compiling + #[macro_use] #[path = "windows/compat.rs"] mod compat; @@ -105,22 +99,16 @@ cfg_if::cfg_if! { } #[cfg(doc)] +#[cfg(not(any( + target_os = "hermit", + all(target_arch = "wasm32", not(target_os = "wasi")), + all(target_vendor = "fortanix", target_env = "sgx") +)))] cfg_if::cfg_if! { if #[cfg(target_os = "wasi")] { - // On WASI we'll document what's already available #[stable(feature = "wasi_ext_doc", since = "1.35.0")] pub use self::ext as wasi_ext; - } else if #[cfg(any(target_os = "hermit", - target_arch = "wasm32", - all(target_vendor = "fortanix", target_env = "sgx")))] { - // On non-WASI wasm right now the module below doesn't compile - // (missing things in `libc` which is empty) so just omit everything - // with an empty module - #[unstable(issue = "none", feature = "std_internals")] - #[allow(missing_docs)] - pub mod wasi_ext {} - } else { - // On other platforms like Windows document the bare bones of WASI + } else { #[path = "wasi/ext/mod.rs"] #[stable(feature = "wasi_ext_doc", since = "1.35.0")] pub mod wasi_ext; |
