diff --git a/library/std/src/io/copy.rs b/library/std/src/io/copy.rs index db47ba97fe4..b88bca2f2b4 100644 --- a/library/std/src/io/copy.rs +++ b/library/std/src/io/copy.rs @@ -1,9 +1,6 @@ use crate::io::{self, ErrorKind, Read, Write}; use crate::mem::MaybeUninit; -#[cfg(all(test, unix))] -mod tests; - /// Copies the entire contents of a reader into a writer. /// /// This function will continuously read data from `reader` and then diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index 81cc0a59eb6..0b162f9b300 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -1214,7 +1214,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { /// if one of the files' cursor +`max_len` would exceed u64::MAX (`EOVERFLOW`). /// If the initial file offset was 0 then `Fallback` will only contain `0`. #[cfg(any(target_os = "linux", target_os = "android"))] -pub(crate) fn copy_regular_files(reader: RawFd, writer: RawFd, max_len: u64) -> CopyResult { +pub(super) fn copy_regular_files(reader: RawFd, writer: RawFd, max_len: u64) -> CopyResult { use crate::cmp; use crate::sync::atomic::{AtomicBool, Ordering}; @@ -1302,12 +1302,12 @@ pub(crate) fn copy_regular_files(reader: RawFd, writer: RawFd, max_len: u64) -> } #[derive(PartialEq)] -pub(crate) enum SpliceMode { +pub(super) enum SpliceMode { Sendfile, Splice, } -pub(crate) enum CopyResult { +pub(super) enum CopyResult { Ended(io::Result), Fallback(u64), } @@ -1315,7 +1315,7 @@ pub(crate) enum CopyResult { /// performs splice or sendfile between file descriptors /// Does _not_ fall back to a generic copy loop. #[cfg(any(target_os = "linux", target_os = "android"))] -pub(crate) fn sendfile_splice( +pub(super) fn sendfile_splice( mode: SpliceMode, reader: RawFd, writer: RawFd, diff --git a/library/std/src/sys/unix/kernel_copy.rs b/library/std/src/sys/unix/kernel_copy.rs index 4b7a5f508d9..d0a9401b30f 100644 --- a/library/std/src/sys/unix/kernel_copy.rs +++ b/library/std/src/sys/unix/kernel_copy.rs @@ -58,6 +58,9 @@ use crate::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use crate::process::{ChildStderr, ChildStdin, ChildStdout}; use crate::sys::fs::{copy_regular_files, sendfile_splice, CopyResult, SpliceMode}; +#[cfg(test)] +mod tests; + pub(crate) fn copy_spec( read: &mut R, write: &mut W, diff --git a/library/std/src/io/copy/tests.rs b/library/std/src/sys/unix/kernel_copy/tests.rs similarity index 100% rename from library/std/src/io/copy/tests.rs rename to library/std/src/sys/unix/kernel_copy/tests.rs