From 132ec261b0d215f77b71eeee3d814cd304fc1a29 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 22 Feb 2021 14:21:43 -0800 Subject: Enable API documentation for `std::os::wasi`. This adds API documentation support for `std::os::wasi` modeled after how `std::os::unix` works, so that WASI can be documented [here] along with the other platforms. [here]: https://doc.rust-lang.org/stable/std/os/index.html Two changes of particular interest: - This changes the `AsRawFd` for `io::Stdin` for WASI to return `libc::STDIN_FILENO` instead of `sys::stdio::Stdin.as_raw_fd()` (and similar for `Stdout` and `Stderr`), which matches how the `unix` version works. `STDIN_FILENO` etc. may not always be explicitly reserved at the WASI level, but as long as we have Rust's `std` and `libc`, I think it's reasonable to guarantee that we'll always use `libc::STDIN_FILENO` for stdin. - This duplicates the `osstr2str` utility function, rather than trying to share it across all the configurations that need it. --- library/std/src/os/mod.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'library/std/src/os') diff --git a/library/std/src/os/mod.rs b/library/std/src/os/mod.rs index f61e402e370..fad5886def7 100644 --- a/library/std/src/os/mod.rs +++ b/library/std/src/os/mod.rs @@ -22,6 +22,9 @@ pub use crate::sys::windows_ext as windows; #[doc(cfg(target_os = "linux"))] pub mod linux; +#[cfg(doc)] +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))] -- cgit 1.4.1-3-g733a5 From e66e2635442b47808a5e23db83b461c11d2943fc Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 24 Feb 2021 10:43:50 -0800 Subject: Make the main `wasi` module `cfg(not(doc))`. --- library/std/src/os/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'library/std/src/os') diff --git a/library/std/src/os/mod.rs b/library/std/src/os/mod.rs index fad5886def7..ca8c4c9c420 100644 --- a/library/std/src/os/mod.rs +++ b/library/std/src/os/mod.rs @@ -41,6 +41,10 @@ pub use crate::sys::ext as windows; #[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")] @@ -71,7 +75,5 @@ pub mod redox; pub mod solaris; #[cfg(target_os = "vxworks")] pub mod vxworks; -#[cfg(target_os = "wasi")] -pub mod wasi; pub mod raw; -- cgit 1.4.1-3-g733a5 From 94e75acf1fd5933ba5821e9b1935796f0bbf23e0 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 24 Feb 2021 10:47:26 -0800 Subject: Mention "wasi" in the comment about "main modules". --- library/std/src/os/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'library/std/src/os') diff --git a/library/std/src/os/mod.rs b/library/std/src/os/mod.rs index ca8c4c9c420..500e8267cf8 100644 --- a/library/std/src/os/mod.rs +++ b/library/std/src/os/mod.rs @@ -3,7 +3,7 @@ #![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 modules as these are the "main +// 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. -- cgit 1.4.1-3-g733a5