about summary refs log tree commit diff
path: root/library/std/src/os
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-02-27 02:34:27 +0100
committerGitHub <noreply@github.com>2021-02-27 02:34:27 +0100
commitf5b68a4444a96f8a2915dfa8b7fc9b641f56bdf2 (patch)
tree69e776f6f0bccd70103155bd699250f765bf6d2f /library/std/src/os
parent76b40d27e2946fe6118ec9d9a6f4a49aa1945800 (diff)
parent7d5242a03a9e30fe880ff1af83a3ad7df5e62159 (diff)
downloadrust-f5b68a4444a96f8a2915dfa8b7fc9b641f56bdf2.tar.gz
rust-f5b68a4444a96f8a2915dfa8b7fc9b641f56bdf2.zip
Rollup merge of #82420 - sunfishcode:wasi-docs, r=alexcrichton
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.

r? ```@alexcrichton```
Diffstat (limited to 'library/std/src/os')
-rw-r--r--library/std/src/os/mod.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/library/std/src/os/mod.rs b/library/std/src/os/mod.rs
index f61e402e370..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.
@@ -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))]
@@ -38,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")]
@@ -68,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;