Skip to content

Commit b4dfa19

Browse files
committed
Fix doc test failures on Windows.
1 parent e555003 commit b4dfa19

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

library/std/src/os/fd/owned.rs

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ pub trait AsFd {
159159
/// # use std::os::unix::io::{AsFd, BorrowedFd};
160160
///
161161
/// let mut f = File::open("foo.txt")?;
162+
/// # #[cfg(any(unix, target_os = "wasi"))]
162163
/// let borrowed_fd: BorrowedFd<'_> = f.as_fd();
163164
/// # Ok::<(), io::Error>(())
164165
/// ```

library/std/src/os/fd/raw.rs

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub trait AsRawFd {
4040
///
4141
/// let mut f = File::open("foo.txt")?;
4242
/// // Note that `raw_fd` is only valid as long as `f` exists.
43+
/// #[cfg(any(unix, target_os = "wasi"))]
4344
/// let raw_fd: RawFd = f.as_raw_fd();
4445
/// # Ok::<(), io::Error>(())
4546
/// ```
@@ -75,9 +76,11 @@ pub trait FromRawFd {
7576
/// use std::os::wasi::io::{FromRawFd, IntoRawFd, RawFd};
7677
///
7778
/// let f = File::open("foo.txt")?;
79+
/// # #[cfg(any(unix, target_os = "wasi"))]
7880
/// let raw_fd: RawFd = f.into_raw_fd();
7981
/// // SAFETY: no other functions should call `from_raw_fd`, so there
8082
/// // is only one owner for the file descriptor.
83+
/// # #[cfg(any(unix, target_os = "wasi"))]
8184
/// let f = unsafe { File::from_raw_fd(raw_fd) };
8285
/// # Ok::<(), io::Error>(())
8386
/// ```
@@ -106,6 +109,7 @@ pub trait IntoRawFd {
106109
/// use std::os::wasi::io::{IntoRawFd, RawFd};
107110
///
108111
/// let f = File::open("foo.txt")?;
112+
/// #[cfg(any(unix, target_os = "wasi"))]
109113
/// let raw_fd: RawFd = f.into_raw_fd();
110114
/// # Ok::<(), io::Error>(())
111115
/// ```

library/std/src/os/windows/io/handle.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,10 @@ pub trait AsHandle {
237237
/// # Example
238238
///
239239
/// ```rust,no_run
240+
/// # #![feature(io_safety)]
240241
/// use std::fs::File;
241242
/// # use std::io;
242-
/// use std::os::windows::{AsHandle, BorrowedHandle};
243+
/// use std::os::windows::io::{AsHandle, BorrowedHandle};
243244
///
244245
/// let mut f = File::open("foo.txt")?;
245246
/// let borrowed_handle: BorrowedHandle<'_> = f.as_handle();

0 commit comments

Comments
 (0)