mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 21:47:04 +00:00
Return OutOfMemoryError and update docs
(cherry picked from commit 3cb53df1fe
)
This commit is contained in:
parent
e616d37b33
commit
3aa36cf951
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user