Skip to content

Commit d094e72

Browse files
authored
Merge pull request #7962 from cakebaker/mv_remove_unnecessary_result
mv: use `bool` instead of `Result` as return type
2 parents 4fd11ab + dde7324 commit d094e72

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/uu/mv/src/mv.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,8 @@ fn rename_with_fallback(
698698
// 1. Files are on different devices (EXDEV error)
699699
// 2. On Windows, if the target file exists and source file is opened by another process
700700
// (MoveFileExW fails with "Access Denied" even if the source file has FILE_SHARE_DELETE permission)
701-
let should_fallback = matches!(err.raw_os_error(), Some(EXDEV))
702-
|| (from.is_file() && can_delete_file(from).unwrap_or(false));
701+
let should_fallback =
702+
matches!(err.raw_os_error(), Some(EXDEV)) || (from.is_file() && can_delete_file(from));
703703
if !should_fallback {
704704
return Err(err);
705705
}
@@ -864,7 +864,7 @@ fn is_empty_dir(path: &Path) -> bool {
864864

865865
/// Checks if a file can be deleted by attempting to open it with delete permissions.
866866
#[cfg(windows)]
867-
fn can_delete_file(path: &Path) -> Result<bool, io::Error> {
867+
fn can_delete_file(path: &Path) -> bool {
868868
use std::{
869869
os::windows::ffi::OsStrExt as _,
870870
ptr::{null, null_mut},
@@ -897,19 +897,19 @@ fn can_delete_file(path: &Path) -> Result<bool, io::Error> {
897897
};
898898

899899
if handle == INVALID_HANDLE_VALUE {
900-
return Err(io::Error::last_os_error());
900+
return false;
901901
}
902902

903903
unsafe { CloseHandle(handle) };
904904

905-
Ok(true)
905+
true
906906
}
907907

908908
#[cfg(not(windows))]
909-
fn can_delete_file(_: &Path) -> Result<bool, io::Error> {
909+
fn can_delete_file(_: &Path) -> bool {
910910
// On non-Windows platforms, always return false to indicate that we don't need
911911
// to try the copy+delete fallback. This is because on Unix-like systems,
912912
// rename() failing with errors other than EXDEV means the operation cannot
913913
// succeed even with a copy+delete approach (e.g. permission errors).
914-
Ok(false)
914+
false
915915
}

0 commit comments

Comments
 (0)