Skip to content

Commit 12b230b

Browse files
ChrisDentoncuviper
authored andcommitted
Return OutOfMemoryError and update docs
(cherry picked from commit 3cb53df)
1 parent 954222d commit 12b230b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

library/std/src/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2402,7 +2402,7 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
24022402
/// # Platform-specific behavior
24032403
///
24042404
/// This function currently corresponds to the `rename` function on Unix
2405-
/// and the `SetFileInformationByHandle` function on Windows.
2405+
/// and the `MoveFileExW` or `SetFileInformationByHandle` function on Windows.
24062406
///
24072407
/// Because of this, the behavior when both `from` and `to` exist differs. On
24082408
/// Unix, if `from` is a directory, `to` must also be an (empty) directory. If

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

Lines changed: 2 additions & 2 deletions
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};
@@ -1266,7 +1266,7 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
12661266
unsafe {
12671267
file_rename_info = alloc(layout).cast::<c::FILE_RENAME_INFO>();
12681268
if file_rename_info.is_null() {
1269-
handle_alloc_error(layout);
1269+
return Err(io::ErrorKind::OutOfMemory.into());
12701270
}
12711271

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

0 commit comments

Comments
 (0)