Skip to content

Commit

Permalink
Rollup merge of rust-lang#88619 - GuillaumeGomez:simplify-std-os-reex…
Browse files Browse the repository at this point in the history
…ports, r=Amanieu

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

Fixes rust-lang#88304.

I tested it based on rust-lang#88292.

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

cc ``@jyn514``
  • Loading branch information
GuillaumeGomez authored Sep 11, 2021
2 parents 24fed97 + 88d5aa6 commit f064ad7
Showing 1 changed file with 103 additions and 99 deletions.
202 changes: 103 additions & 99 deletions library/std/src/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,117 +10,121 @@ pub mod raw;
// of a macro that is not vendored by Rust and included in the toolchain.
// See https://github.com/rust-analyzer/rust-analyzer/issues/6038.

// 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 and add the "unstable" attribute.

// Unix, linux, wasi and windows are handled a bit differently.
#[cfg(all(
doc,
not(any(
any(
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;

pub mod linux;

pub mod wasi;

pub mod windows;
}
#[unstable(issue = "none", feature = "std_internals")]
pub mod unix {}
#[cfg(all(
doc,
any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)
))]
mod 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 {}
}
#[cfg(doc)]
#[stable(feature = "os", since = "1.0.0")]
pub use doc::*;

#[cfg(not(doc))]
#[path = "."]
mod imp {
// 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(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::*;
#[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 {}

// unix
#[cfg(not(any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)))]
#[cfg(all(not(doc), target_os = "hermit"))]
#[path = "hermit/mod.rs"]
pub mod unix;
#[cfg(not(any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)))]
#[cfg(any(unix, doc))]
pub mod unix;

// linux
#[cfg(not(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;

// wasi
#[cfg(not(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;

// windows
#[cfg(not(any(
all(target_arch = "wasm32", not(target_os = "wasi")),
all(target_vendor = "fortanix", target_env = "sgx")
)))]
#[cfg(any(windows, doc))]
pub mod windows;

// Others.
#[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(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;

#[cfg(any(unix, target_os = "wasi", doc))]
mod fd;

0 comments on commit f064ad7

Please sign in to comment.