From 20fd81ebd328b6089afcb8e2355841b5210075ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Mon, 17 Nov 2025 17:23:55 +0100 Subject: [PATCH 1/5] doc: fix `strict_provenance_lints` tracking issue link --- .../src/language-features/strict-provenance-lints.md | 4 ++-- src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/unstable-book/src/language-features/strict-provenance-lints.md b/src/doc/unstable-book/src/language-features/strict-provenance-lints.md index 81bdf07a86af9..fec908fe3212e 100644 --- a/src/doc/unstable-book/src/language-features/strict-provenance-lints.md +++ b/src/doc/unstable-book/src/language-features/strict-provenance-lints.md @@ -1,8 +1,8 @@ # `strict_provenance_lints` -The tracking issue for this feature is: [#95228] +The tracking issue for this feature is: [#130351] -[#95228]: https://github.com/rust-lang/rust/issues/95228 +[#130351]: https://github.com/rust-lang/rust/issues/130351 ----- The `strict_provenance_lints` feature allows to enable the `fuzzy_provenance_casts` and `lossy_provenance_casts` lints. diff --git a/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs b/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs index 5eb7e92ffb096..7f4dad873cd6f 100644 --- a/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs +++ b/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs @@ -10723,9 +10723,9 @@ The tracking issue for this feature is: [#99108] label: "strict_provenance_lints", description: r##"# `strict_provenance_lints` -The tracking issue for this feature is: [#95228] +The tracking issue for this feature is: [#130351] -[#95228]: https://github.com/rust-lang/rust/issues/95228 +[#130351]: https://github.com/rust-lang/rust/issues/130351 ----- The `strict_provenance_lints` feature allows to enable the `fuzzy_provenance_casts` and `lossy_provenance_casts` lints. From d8701496725370f49668c56118ad58cbca508e89 Mon Sep 17 00:00:00 2001 From: joboet Date: Fri, 26 Sep 2025 21:46:48 +0200 Subject: [PATCH 2/5] std: move `kernel_copy` to `sys` --- library/std/src/io/copy.rs | 15 ++++---- library/std/src/sys/fs/mod.rs | 2 +- library/std/src/sys/fs/unix.rs | 2 +- .../kernel_copy/linux.rs} | 35 ++++++++++--------- .../kernel_copy/linux}/tests.rs | 0 library/std/src/sys/io/kernel_copy/mod.rs | 23 ++++++++++++ library/std/src/sys/io/mod.rs | 3 ++ library/std/src/sys/pal/unix/mod.rs | 2 -- 8 files changed, 54 insertions(+), 28 deletions(-) rename library/std/src/sys/{pal/unix/kernel_copy.rs => io/kernel_copy/linux.rs} (97%) rename library/std/src/sys/{pal/unix/kernel_copy => io/kernel_copy/linux}/tests.rs (100%) create mode 100644 library/std/src/sys/io/kernel_copy/mod.rs diff --git a/library/std/src/io/copy.rs b/library/std/src/io/copy.rs index d060ad528973f..2b558efb8885e 100644 --- a/library/std/src/io/copy.rs +++ b/library/std/src/io/copy.rs @@ -4,6 +4,7 @@ use crate::cmp; use crate::collections::VecDeque; use crate::io::IoSlice; use crate::mem::MaybeUninit; +use crate::sys::io::{CopyState, kernel_copy}; #[cfg(test)] mod tests; @@ -63,19 +64,17 @@ where R: Read, W: Write, { - cfg_select! { - any(target_os = "linux", target_os = "android") => { - crate::sys::kernel_copy::copy_spec(reader, writer) - } - _ => { - generic_copy(reader, writer) + match kernel_copy(reader, writer)? { + CopyState::Ended(copied) => Ok(copied), + CopyState::Fallback(copied) => { + generic_copy(reader, writer).map(|additional| copied + additional) } } } /// The userspace read-write-loop implementation of `io::copy` that is used when /// OS-specific specializations for copy offloading are not available or not applicable. -pub(crate) fn generic_copy(reader: &mut R, writer: &mut W) -> Result +fn generic_copy(reader: &mut R, writer: &mut W) -> Result where R: Read, W: Write, @@ -269,7 +268,7 @@ impl BufferedWriterSpec for Vec { } } -pub fn stack_buffer_copy( +fn stack_buffer_copy( reader: &mut R, writer: &mut W, ) -> Result { diff --git a/library/std/src/sys/fs/mod.rs b/library/std/src/sys/fs/mod.rs index bc1052b6f8c55..eaea28871241a 100644 --- a/library/std/src/sys/fs/mod.rs +++ b/library/std/src/sys/fs/mod.rs @@ -14,7 +14,7 @@ cfg_select! { pub use unix::chroot; pub(crate) use unix::debug_assert_fd_is_open; #[cfg(any(target_os = "linux", target_os = "android"))] - pub(crate) use unix::CachedFileMetadata; + pub(super) use unix::CachedFileMetadata; use crate::sys::common::small_c_string::run_path_with_cstr as with_native_path; } target_os = "windows" => { diff --git a/library/std/src/sys/fs/unix.rs b/library/std/src/sys/fs/unix.rs index cadcfddb0f7f8..47d9ee226653e 100644 --- a/library/std/src/sys/fs/unix.rs +++ b/library/std/src/sys/fs/unix.rs @@ -2302,7 +2302,7 @@ mod cfm { } } #[cfg(any(target_os = "linux", target_os = "android"))] -pub(crate) use cfm::CachedFileMetadata; +pub(in crate::sys) use cfm::CachedFileMetadata; #[cfg(not(target_vendor = "apple"))] pub fn copy(from: &Path, to: &Path) -> io::Result { diff --git a/library/std/src/sys/pal/unix/kernel_copy.rs b/library/std/src/sys/io/kernel_copy/linux.rs similarity index 97% rename from library/std/src/sys/pal/unix/kernel_copy.rs rename to library/std/src/sys/io/kernel_copy/linux.rs index b984afa149d06..1c00d317f2a52 100644 --- a/library/std/src/sys/pal/unix/kernel_copy.rs +++ b/library/std/src/sys/io/kernel_copy/linux.rs @@ -48,9 +48,9 @@ use libc::sendfile as sendfile64; use libc::sendfile64; use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV}; +use super::CopyState; use crate::cmp::min; use crate::fs::{File, Metadata}; -use crate::io::copy::generic_copy; use crate::io::{ BufRead, BufReader, BufWriter, Error, PipeReader, PipeWriter, Read, Result, StderrLock, StdinLock, StdoutLock, Take, Write, @@ -70,10 +70,10 @@ use crate::sys::weak::syscall; #[cfg(test)] mod tests; -pub(crate) fn copy_spec( +pub fn kernel_copy( read: &mut R, write: &mut W, -) -> Result { +) -> Result { let copier = Copier { read, write }; SpecCopy::copy(copier) } @@ -176,17 +176,17 @@ struct Copier<'a, 'b, R: Read + ?Sized, W: Write + ?Sized> { } trait SpecCopy { - fn copy(self) -> Result; + fn copy(self) -> Result; } impl SpecCopy for Copier<'_, '_, R, W> { - default fn copy(self) -> Result { - generic_copy(self.read, self.write) + default fn copy(self) -> Result { + Ok(CopyState::Fallback(0)) } } impl SpecCopy for Copier<'_, '_, R, W> { - fn copy(self) -> Result { + fn copy(self) -> Result { let (reader, writer) = (self.read, self.write); let r_cfg = reader.properties(); let w_cfg = writer.properties(); @@ -214,7 +214,9 @@ impl SpecCopy for Copier<'_, '_, R, W> { result.update_take(reader); match result { - CopyResult::Ended(bytes_copied) => return Ok(bytes_copied + written), + CopyResult::Ended(bytes_copied) => { + return Ok(CopyState::Ended(bytes_copied + written)); + } CopyResult::Error(e, _) => return Err(e), CopyResult::Fallback(bytes) => written += bytes, } @@ -231,7 +233,9 @@ impl SpecCopy for Copier<'_, '_, R, W> { result.update_take(reader); match result { - CopyResult::Ended(bytes_copied) => return Ok(bytes_copied + written), + CopyResult::Ended(bytes_copied) => { + return Ok(CopyState::Ended(bytes_copied + written)); + } CopyResult::Error(e, _) => return Err(e), CopyResult::Fallback(bytes) => written += bytes, } @@ -244,7 +248,9 @@ impl SpecCopy for Copier<'_, '_, R, W> { result.update_take(reader); match result { - CopyResult::Ended(bytes_copied) => return Ok(bytes_copied + written), + CopyResult::Ended(bytes_copied) => { + return Ok(CopyState::Ended(bytes_copied + written)); + } CopyResult::Error(e, _) => return Err(e), CopyResult::Fallback(0) => { /* use the fallback below */ } CopyResult::Fallback(_) => { @@ -255,10 +261,7 @@ impl SpecCopy for Copier<'_, '_, R, W> { } // fallback if none of the more specialized syscalls wants to work with these file descriptors - match generic_copy(reader, writer) { - Ok(bytes) => Ok(bytes + written), - err => err, - } + Ok(CopyState::Fallback(written)) } } @@ -558,7 +561,7 @@ fn fd_to_meta(fd: &T) -> FdMeta { } } -pub(super) enum CopyResult { +enum CopyResult { Ended(u64), Error(Error, u64), Fallback(u64), @@ -587,7 +590,7 @@ const INVALID_FD: RawFd = -1; /// Callers must handle fallback to a generic copy loop. /// `Fallback` may indicate non-zero number of bytes already written /// if one of the files' cursor +`max_len` would exceed u64::MAX (`EOVERFLOW`). -pub(super) fn copy_regular_files(reader: RawFd, writer: RawFd, max_len: u64) -> CopyResult { +fn copy_regular_files(reader: RawFd, writer: RawFd, max_len: u64) -> CopyResult { use crate::cmp; const NOT_PROBED: u8 = 0; diff --git a/library/std/src/sys/pal/unix/kernel_copy/tests.rs b/library/std/src/sys/io/kernel_copy/linux/tests.rs similarity index 100% rename from library/std/src/sys/pal/unix/kernel_copy/tests.rs rename to library/std/src/sys/io/kernel_copy/linux/tests.rs diff --git a/library/std/src/sys/io/kernel_copy/mod.rs b/library/std/src/sys/io/kernel_copy/mod.rs new file mode 100644 index 0000000000000..a89279412cf7f --- /dev/null +++ b/library/std/src/sys/io/kernel_copy/mod.rs @@ -0,0 +1,23 @@ +pub enum CopyState { + #[cfg_attr(not(any(target_os = "linux", target_os = "android")), expect(dead_code))] + Ended(u64), + Fallback(u64), +} + +cfg_select! { + any(target_os = "linux", target_os = "android") => { + mod linux; + pub use linux::kernel_copy; + } + _ => { + use crate::io::{Result, Read, Write}; + + pub fn kernel_copy(_reader: &mut R, _writer: &mut W) -> Result + where + R: Read, + W: Write, + { + Ok(CopyState::Fallback(0)) + } + } +} diff --git a/library/std/src/sys/io/mod.rs b/library/std/src/sys/io/mod.rs index 0916eda1c06a5..e2c5e7f88d492 100644 --- a/library/std/src/sys/io/mod.rs +++ b/library/std/src/sys/io/mod.rs @@ -50,8 +50,11 @@ mod is_terminal { } } +mod kernel_copy; + pub use io_slice::{IoSlice, IoSliceMut}; pub use is_terminal::is_terminal; +pub use kernel_copy::{CopyState, kernel_copy}; // Bare metal platforms usually have very small amounts of RAM // (in the order of hundreds of KB) diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs index 9d303b8d65b39..81533d593131b 100644 --- a/library/std/src/sys/pal/unix/mod.rs +++ b/library/std/src/sys/pal/unix/mod.rs @@ -5,8 +5,6 @@ use crate::io::ErrorKind; #[cfg(target_os = "fuchsia")] pub mod fuchsia; pub mod futex; -#[cfg(any(target_os = "linux", target_os = "android"))] -pub mod kernel_copy; #[cfg(target_os = "linux")] pub mod linux; pub mod os; From d589d2f40b78fab69bc706c821bd459244d9d1d5 Mon Sep 17 00:00:00 2001 From: joboet Date: Fri, 26 Sep 2025 21:56:04 +0200 Subject: [PATCH 3/5] tidy: remove obsolete exceptions from pal test --- src/tools/tidy/src/pal.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/tools/tidy/src/pal.rs b/src/tools/tidy/src/pal.rs index f03dde6257d76..e5945a72d32a0 100644 --- a/src/tools/tidy/src/pal.rs +++ b/src/tools/tidy/src/pal.rs @@ -59,12 +59,9 @@ const EXCEPTION_PATHS: &[&str] = &[ "library/std/src/os", // Platform-specific public interfaces // Temporary `std` exceptions // FIXME: platform-specific code should be moved to `sys` - "library/std/src/io/copy.rs", "library/std/src/io/stdio.rs", "library/std/src/lib.rs", // for miniz_oxide leaking docs, which itself workaround "library/std/src/path.rs", - "library/std/src/sys_common", // Should only contain abstractions over platforms - "library/std/src/net/test.rs", // Utility helpers for tests "library/std/src/io/error.rs", // Repr unpacked needed for UEFI ]; From 221683ca1bf482009971480ddc08bbb6cb7d5de2 Mon Sep 17 00:00:00 2001 From: rustbot <47979223+rustbot@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:01:12 +0100 Subject: [PATCH 4/5] Update books --- src/doc/book | 2 +- src/doc/edition-guide | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/book b/src/doc/book index f660f341887c8..f78ab89d7545a 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit f660f341887c8bbcd6c24fbfdf5d2a262f523965 +Subproject commit f78ab89d7545ac17780e6a367055cc089f4cd2ec diff --git a/src/doc/edition-guide b/src/doc/edition-guide index 5c621253d8f2a..9cf5443d63267 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit 5c621253d8f2a5a4adb64a6365905db67dffe3a2 +Subproject commit 9cf5443d632673c4d41edad5e8ed8be86eeb3b8f diff --git a/src/doc/nomicon b/src/doc/nomicon index 60f0b30d8ec1c..0fe83ab28985b 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit 60f0b30d8ec1c9eb5c2582f2ec55f1094b0f8c42 +Subproject commit 0fe83ab28985b99aba36a1f0dbde3e08286fefda diff --git a/src/doc/reference b/src/doc/reference index e122eefff3fef..f9f1d2a4149f0 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit e122eefff3fef362eb7e0c08fb7ffbf5f9461905 +Subproject commit f9f1d2a4149f02582aec2f8fcdfa5b596193b4e2 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 160e6bbca70b0..f944161716230 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 160e6bbca70b0c01aa4de88d19db7fc5ff8447c3 +Subproject commit f944161716230641605b5e3733e1c81f10047fd4 From 203086ca6dce292faaa47e0e9b36b7609571e0f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Mon, 17 Nov 2025 19:21:31 +0100 Subject: [PATCH 5/5] update my email in mailmap --- .mailmap | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.mailmap b/.mailmap index 5c765fc547e73..21b0a05aefffa 100644 --- a/.mailmap +++ b/.mailmap @@ -448,9 +448,10 @@ Martin Habovštiak Martin Hafskjold Thoresen Martin Nordholts Matej Lach Matej Ľach -Mateusz Mikuła -Mateusz Mikuła -Mateusz Mikuła +Mateusz Mikuła +Mateusz Mikuła +Mateusz Mikuła +Mateusz Mikuła Matt Brubeck Matthew Auld Matthew Jasper