about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorChris Denton <chris@chrisdenton.dev>2025-03-06 14:18:18 +0000
committerChris Denton <chris@chrisdenton.dev>2025-03-07 17:51:56 +0000
commit3cb53df1feaba73b84344c8c0e3dc4120ad8c95b (patch)
treedae1469a51c1521dd16d6c560d3f81886385993c /library/std/src
parent0dfe2ae3fb72c50ea369286131c73daede13d7e5 (diff)
downloadrust-3cb53df1feaba73b84344c8c0e3dc4120ad8c95b.tar.gz
rust-3cb53df1feaba73b84344c8c0e3dc4120ad8c95b.zip
Return OutOfMemoryError and update docs
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/fs.rs2
-rw-r--r--library/std/src/sys/pal/windows/fs.rs4
2 files changed, 3 insertions, 3 deletions
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs
index 4314c8a0b18..46b5860123f 100644
--- a/library/std/src/fs.rs
+++ b/library/std/src/fs.rs
@@ -2446,7 +2446,7 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
 /// # Platform-specific behavior
 ///
 /// This function currently corresponds to the `rename` function on Unix
-/// and the `SetFileInformationByHandle` function on Windows.
+/// and the `MoveFileExW` or `SetFileInformationByHandle` function on Windows.
 ///
 /// Because of this, the behavior when both `from` and `to` exist differs. On
 /// Unix, if `from` is a directory, `to` must also be an (empty) directory. If
diff --git a/library/std/src/sys/pal/windows/fs.rs b/library/std/src/sys/pal/windows/fs.rs
index 34108e44d58..8fce0496d80 100644
--- a/library/std/src/sys/pal/windows/fs.rs
+++ b/library/std/src/sys/pal/windows/fs.rs
@@ -1,6 +1,6 @@
 use super::api::{self, WinError, set_file_information_by_handle};
 use super::{IoResult, to_u16s};
-use crate::alloc::{Layout, alloc, dealloc, handle_alloc_error};
+use crate::alloc::{Layout, alloc, dealloc};
 use crate::borrow::Cow;
 use crate::ffi::{OsStr, OsString, c_void};
 use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom};
@@ -1269,7 +1269,7 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
             unsafe {
                 file_rename_info = alloc(layout).cast::<c::FILE_RENAME_INFO>();
                 if file_rename_info.is_null() {
-                    handle_alloc_error(layout);
+                    return Err(io::ErrorKind::OutOfMemory.into());
                 }
 
                 (&raw mut (*file_rename_info).Anonymous).write(c::FILE_RENAME_INFO_0 {