Skip to content

Commit 9b20ca1

Browse files
ChrisDentoncuviper
authored andcommitted
Return OutOfMemoryError and update docs
(cherry picked from commit 3cb53df)
1 parent 882139c commit 9b20ca1

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
@@ -2425,7 +2425,7 @@ pub fn symlink_metadata<P: AsRef<Path>>(path: P) -> io::Result<Metadata> {
24252425
/// # Platform-specific behavior
24262426
///
24272427
/// This function currently corresponds to the `rename` function on Unix
2428-
/// and the `SetFileInformationByHandle` function on Windows.
2428+
/// and the `MoveFileExW` or `SetFileInformationByHandle` function on Windows.
24292429
///
24302430
/// Because of this, the behavior when both `from` and `to` exist differs. On
24312431
/// 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};
@@ -1280,7 +1280,7 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
12801280
unsafe {
12811281
file_rename_info = alloc(layout).cast::<c::FILE_RENAME_INFO>();
12821282
if file_rename_info.is_null() {
1283-
handle_alloc_error(layout);
1283+
return Err(io::ErrorKind::OutOfMemory.into());
12841284
}
12851285

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

0 commit comments

Comments
 (0)