@@ -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" ) ]
356356fn 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