Skip to content

Commit 77875aa

Browse files
committed
clippy checks
1 parent 0390f74 commit 77875aa

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.vscode/cspell.dictionaries/jargon.wordlist.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,8 @@ nofield
175175
# * clippy
176176
uninlined
177177
nonminimal
178+
179+
# * mv exchange functionality
180+
renameat
181+
FDCWD
182+
ENOTSUP

src/uu/mv/src/mv.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,17 @@ fn determine_overwrite_mode(matches: &ArgMatches) -> OverwriteMode {
351351
}
352352
}
353353

354-
/// Atomically exchange two files using renameat2 with RENAME_EXCHANGE
354+
/// Atomically exchange two files using renameat2 with `RENAME_EXCHANGE`
355355
#[cfg(target_os = "linux")]
356356
fn exchange_files(path1: &Path, path2: &Path, opts: &Options) -> UResult<()> {
357357
use std::ffi::CString;
358358
use std::os::unix::ffi::OsStrExt;
359359

360360
// Convert paths to C strings
361361
let c_path1 = CString::new(path1.as_os_str().as_bytes())
362-
.map_err(|e| USimpleError::new(1, format!("Invalid path {}: {}", path1.display(), e)))?;
362+
.map_err(|e| USimpleError::new(1, format!("Invalid path {}: {e}", path1.display())))?;
363363
let c_path2 = CString::new(path2.as_os_str().as_bytes())
364-
.map_err(|e| USimpleError::new(1, format!("Invalid path {}: {}", path2.display(), e)))?;
364+
.map_err(|e| USimpleError::new(1, format!("Invalid path {}: {e}", path2.display())))?;
365365

366366
// RENAME_EXCHANGE flag for renameat2
367367
const RENAME_EXCHANGE: libc::c_int = 2;
@@ -391,18 +391,18 @@ fn exchange_files(path1: &Path, path2: &Path, opts: &Options) -> UResult<()> {
391391
get_message("mv-error-exchange-not-supported"),
392392
)),
393393
libc::ENOENT => {
394-
let missing_path = if !path1.exists() { path1 } else { path2 };
394+
let missing_path = if path1.exists() { path2 } else { path1 };
395395
Err(MvError::NoSuchFile(missing_path.display().to_string()).into())
396396
}
397397
libc::EXDEV => Err(USimpleError::new(
398398
1,
399399
get_message("mv-error-exchange-cross-device"),
400400
)),
401401
_ => {
402-
let error_msg = std::io::Error::from_raw_os_error(errno);
402+
let error_msg = io::Error::from_raw_os_error(errno);
403403
Err(USimpleError::new(
404404
1,
405-
format!("exchange failed: {}", error_msg),
405+
format!("exchange failed: {error_msg}"),
406406
))
407407
}
408408
}

0 commit comments

Comments
 (0)