1
Fork 0

Auto merge of #88619 - GuillaumeGomez:simplify-std-os-reexports, r=Amanieu

Remove `cfg(doc)` from std::os module reexports to fix rustdoc linking issues

Fixes https://github.com/rust-lang/rust/issues/88304.

I tested it based on https://github.com/rust-lang/rust/pull/88292.

Not sure if it's the best approach, but at least it makes thing a bit simpler.

cc `@jyn514`
This commit is contained in:
bors 2021-09-15 09:30:00 +00:00
commit e846f9c44f
2 changed files with 117 additions and 98 deletions

View file

@ -10,29 +10,11 @@ pub mod raw;
// of a macro that is not vendored by Rust and included in the toolchain. // of a macro that is not vendored by Rust and included in the toolchain.
// See https://github.com/rust-analyzer/rust-analyzer/issues/6038. // See https://github.com/rust-analyzer/rust-analyzer/issues/6038.
#[cfg(all( // On certain platforms right now the "main modules" modules that are
doc, // documented don't compile (missing things in `libc` which is empty),
not(any( // so just omit them with an empty module and add the "unstable" attribute.
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
))
))]
#[path = "."]
mod doc {
// 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.
pub mod unix; // Unix, linux, wasi and windows are handled a bit differently.
pub mod linux;
pub mod wasi;
pub mod windows;
}
#[cfg(all( #[cfg(all(
doc, doc,
any( any(
@ -40,87 +22,124 @@ mod doc {
all(target_vendor = "fortanix", target_env = "sgx") all(target_vendor = "fortanix", target_env = "sgx")
) )
))] ))]
mod doc { #[unstable(issue = "none", feature = "std_internals")]
// On certain platforms right now the "main modules" modules that are pub mod unix {}
// documented don't compile (missing things in `libc` which is empty), #[cfg(all(
// so just omit them with an empty module. doc,
any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)
))]
#[unstable(issue = "none", feature = "std_internals")]
pub mod linux {}
#[cfg(all(
doc,
any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)
))]
#[unstable(issue = "none", feature = "std_internals")]
pub mod wasi {}
#[cfg(all(
doc,
any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)
))]
#[unstable(issue = "none", feature = "std_internals")]
pub mod windows {}
#[unstable(issue = "none", feature = "std_internals")] // unix
pub mod unix {} #[cfg(not(all(
doc,
any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)
)))]
#[cfg(target_os = "hermit")]
#[path = "hermit/mod.rs"]
pub mod unix;
#[cfg(not(all(
doc,
any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)
)))]
#[cfg(all(not(target_os = "hermit"), any(unix, doc)))]
pub mod unix;
#[unstable(issue = "none", feature = "std_internals")] // linux
pub mod linux {} #[cfg(not(all(
doc,
any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)
)))]
#[cfg(any(target_os = "linux", target_os = "l4re", doc))]
pub mod linux;
#[unstable(issue = "none", feature = "std_internals")] // wasi
pub mod wasi {} #[cfg(not(all(
doc,
any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)
)))]
#[cfg(any(target_os = "wasi", doc))]
pub mod wasi;
#[unstable(issue = "none", feature = "std_internals")] // windows
pub mod windows {} #[cfg(not(all(
} doc,
#[cfg(doc)] any(
#[stable(feature = "os", since = "1.0.0")] all(target_arch = "wasm32", not(target_os = "wasi")),
pub use doc::*; all(target_vendor = "fortanix", target_env = "sgx")
)
)))]
#[cfg(any(windows, doc))]
pub mod windows;
#[cfg(not(doc))] // Others.
#[path = "."] #[cfg(target_os = "android")]
mod imp { pub mod android;
// If we're not documenting std then we only expose modules appropriate for the #[cfg(target_os = "dragonfly")]
// current platform. pub mod dragonfly;
#[cfg(target_os = "emscripten")]
pub mod emscripten;
#[cfg(target_os = "espidf")]
pub mod espidf;
#[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(all(target_vendor = "fortanix", target_env = "sgx"))] #[cfg(target_os = "vxworks")]
pub mod fortanix_sgx; pub mod vxworks;
#[cfg(target_os = "hermit")]
#[path = "hermit/mod.rs"]
pub mod 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 = "espidf")]
pub mod espidf;
#[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(unix)]
pub mod unix;
#[cfg(target_os = "vxworks")]
pub mod vxworks;
#[cfg(target_os = "wasi")]
pub mod wasi;
#[cfg(windows)]
pub mod windows;
}
#[cfg(not(doc))]
#[stable(feature = "os", since = "1.0.0")]
pub use imp::*;
#[cfg(any(unix, target_os = "wasi", doc))] #[cfg(any(unix, target_os = "wasi", doc))]
mod fd; mod fd;

View file

@ -104,7 +104,7 @@ pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 2] = ["parking_lot", "RwLockWri
pub const PATH_BUF_AS_PATH: [&str; 4] = ["std", "path", "PathBuf", "as_path"]; pub const PATH_BUF_AS_PATH: [&str; 4] = ["std", "path", "PathBuf", "as_path"];
pub const PATH_TO_PATH_BUF: [&str; 4] = ["std", "path", "Path", "to_path_buf"]; pub const PATH_TO_PATH_BUF: [&str; 4] = ["std", "path", "Path", "to_path_buf"];
pub const PERMISSIONS: [&str; 3] = ["std", "fs", "Permissions"]; pub const PERMISSIONS: [&str; 3] = ["std", "fs", "Permissions"];
pub const PERMISSIONS_FROM_MODE: [&str; 7] = ["std", "os", "imp", "unix", "fs", "PermissionsExt", "from_mode"]; pub const PERMISSIONS_FROM_MODE: [&str; 6] = ["std", "os", "unix", "fs", "PermissionsExt", "from_mode"];
pub const POLL: [&str; 4] = ["core", "task", "poll", "Poll"]; pub const POLL: [&str; 4] = ["core", "task", "poll", "Poll"];
pub const POLL_PENDING: [&str; 5] = ["core", "task", "poll", "Poll", "Pending"]; pub const POLL_PENDING: [&str; 5] = ["core", "task", "poll", "Poll", "Pending"];
pub const POLL_READY: [&str; 5] = ["core", "task", "poll", "Poll", "Ready"]; pub const POLL_READY: [&str; 5] = ["core", "task", "poll", "Poll", "Ready"];