Skip to content

Commit 3a726b1

Browse files
committed
Return OutOfMemoryError and update docs
1 parent 7e5b1c2 commit 3a726b1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

library/std/src/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2446,7 +2446,7 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
24462446
/// # Platform-specific behavior
24472447
///
24482448
/// This function currently corresponds to the `rename` function on Unix
2449-
/// and the `SetFileInformationByHandle` function on Windows.
2449+
/// and the `MoveFileExW` or `SetFileInformationByHandle` function on Windows.
24502450
///
24512451
/// Because of this, the behavior when both `from` and `to` exist differs. On
24522452
/// Unix, if `from` is a directory, `to` must also be an (empty) directory. If

library/std/src/sys/pal/windows/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::api::{self, WinError};
22
use super::{IoResult, to_u16s};
3-
use crate::alloc::{Layout, alloc, dealloc, handle_alloc_error};
3+
use crate::alloc::{Layout, alloc, dealloc};
44
use crate::borrow::Cow;
55
use crate::ffi::{OsStr, OsString, c_void};
66
use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom};
@@ -1284,7 +1284,7 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
12841284
unsafe {
12851285
file_rename_info = alloc(layout).cast::<c::FILE_RENAME_INFO>();
12861286
if file_rename_info.is_null() {
1287-
handle_alloc_error(layout);
1287+
return Err(io::ErrorKind::OutOfMemory.into());
12881288
}
12891289

12901290
(&raw mut (*file_rename_info).Anonymous).write(c::FILE_RENAME_INFO_0 {

0 commit comments

Comments
 (0)