Return OutOfMemoryError and update docs

(cherry picked from commit 3cb53df1fe)
This commit is contained in:
Chris Denton 2025-03-06 14:18:18 +00:00 committed by Josh Stone
parent e616d37b33
commit 3aa36cf951
2 changed files with 3 additions and 3 deletions

View File

@ -2402,7 +2402,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

View File

@ -1,6 +1,6 @@
use super::api::{self, WinError};
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};
@ -1266,7 +1266,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 {