diff --git a/src/uu/base32/src/base_common.rs b/src/uu/base32/src/base_common.rs index 482a09bad..a3ac13c6b 100644 --- a/src/uu/base32/src/base_common.rs +++ b/src/uu/base32/src/base_common.rs @@ -839,8 +839,7 @@ mod tests { assert_eq!( has_padding(&mut cursor).unwrap(), expected, - "Failed for input: '{}'", - input + "Failed for input: '{input}'" ); } } diff --git a/src/uu/chgrp/src/chgrp.rs b/src/uu/chgrp/src/chgrp.rs index 01a97ae20..1763bbfeb 100644 --- a/src/uu/chgrp/src/chgrp.rs +++ b/src/uu/chgrp/src/chgrp.rs @@ -24,7 +24,7 @@ fn parse_gid_from_str(group: &str) -> Result { // Handle :gid format gid_str .parse::() - .map_err(|_| format!("invalid group id: '{}'", gid_str)) + .map_err(|_| format!("invalid group id: '{gid_str}'")) } else { // Try as group name first match entries::grp2gid(group) { @@ -32,7 +32,7 @@ fn parse_gid_from_str(group: &str) -> Result { // If group name lookup fails, try parsing as raw number Err(_) => group .parse::() - .map_err(|_| format!("invalid group: '{}'", group)), + .map_err(|_| format!("invalid group: '{group}'")), } } } @@ -75,7 +75,7 @@ fn parse_gid_and_uid(matches: &ArgMatches) -> UResult { Err(_) => { return Err(USimpleError::new( 1, - format!("invalid user: '{}'", from_group), + format!("invalid user: '{from_group}'"), )); } } diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index d99284330..0770dc48b 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -317,19 +317,19 @@ pub fn parse_args_from_str(text: &NativeIntStr) -> UResult> } EnvError::EnvMissingClosingQuote(_, _) => USimpleError::new(125, e.to_string()), EnvError::EnvParsingOfVariableMissingClosingBrace(pos) => { - USimpleError::new(125, format!("variable name issue (at {pos}): {}", e)) + USimpleError::new(125, format!("variable name issue (at {pos}): {e}")) } EnvError::EnvParsingOfMissingVariable(pos) => { - USimpleError::new(125, format!("variable name issue (at {pos}): {}", e)) + USimpleError::new(125, format!("variable name issue (at {pos}): {e}")) } EnvError::EnvParsingOfVariableMissingClosingBraceAfterValue(pos) => { - USimpleError::new(125, format!("variable name issue (at {pos}): {}", e)) + USimpleError::new(125, format!("variable name issue (at {pos}): {e}")) } EnvError::EnvParsingOfVariableUnexpectedNumber(pos, _) => { - USimpleError::new(125, format!("variable name issue (at {pos}): {}", e)) + USimpleError::new(125, format!("variable name issue (at {pos}): {e}")) } EnvError::EnvParsingOfVariableExceptedBraceOrColon(pos, _) => { - USimpleError::new(125, format!("variable name issue (at {pos}): {}", e)) + USimpleError::new(125, format!("variable name issue (at {pos}): {e}")) } _ => USimpleError::new(125, format!("Error: {e:?}")), }) diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index fb0a9e771..5f2466f16 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -247,7 +247,7 @@ impl HeadOptions { fn wrap_in_stdout_error(err: io::Error) -> io::Error { io::Error::new( err.kind(), - format!("error writing 'standard output': {}", err), + format!("error writing 'standard output': {err}"), ) } diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index 7251a22bc..09a1d12d1 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -734,10 +734,7 @@ fn parse_separator(value_os: &OsString) -> UResult { match chars.next() { None => Ok(SepSetting::Char(value.into())), Some('0') if c == '\\' => Ok(SepSetting::Byte(0)), - _ => Err(USimpleError::new( - 1, - format!("multi-character tab {}", value), - )), + _ => Err(USimpleError::new(1, format!("multi-character tab {value}"))), } } diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index dcaad9099..8ab5487f8 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -60,7 +60,7 @@ enum LnError { MissingDestination(PathBuf), #[error("extra operand {}\nTry '{} --help' for more information.", - format!("{:?}", _0).trim_matches('"'), _1)] + format!("{_0:?}").trim_matches('"'), _1)] ExtraOperand(OsString, String), } diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index 640d0af41..f135f3672 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -116,7 +116,7 @@ impl std::str::FromStr for QuotingStyle { "shell" => Ok(QuotingStyle::Shell), "shell-escape-always" => Ok(QuotingStyle::ShellEscapeAlways), // The others aren't exposed to the user - _ => Err(format!("Invalid quoting style: {}", s)), + _ => Err(format!("Invalid quoting style: {s}")), } } } @@ -335,9 +335,9 @@ fn quote_file_name(file_name: &str, quoting_style: &QuotingStyle) -> String { match quoting_style { QuotingStyle::Locale | QuotingStyle::Shell => { let escaped = file_name.replace('\'', r"\'"); - format!("'{}'", escaped) + format!("'{escaped}'") } - QuotingStyle::ShellEscapeAlways => format!("\"{}\"", file_name), + QuotingStyle::ShellEscapeAlways => format!("\"{file_name}\""), QuotingStyle::Quote => file_name.to_string(), } } @@ -450,7 +450,7 @@ fn print_integer( let extended = match precision { Precision::NotSpecified => format!("{prefix}{arg}"), Precision::NoNumber => format!("{prefix}{arg}"), - Precision::Number(p) => format!("{prefix}{arg:0>precision$}", precision = p), + Precision::Number(p) => format!("{prefix}{arg:0>p$}"), }; pad_and_print(&extended, flags.left, width, padding_char); } @@ -532,7 +532,7 @@ fn print_unsigned( let s = match precision { Precision::NotSpecified => s, Precision::NoNumber => s, - Precision::Number(p) => format!("{s:0>precision$}", precision = p).into(), + Precision::Number(p) => format!("{s:0>p$}").into(), }; pad_and_print(&s, flags.left, width, padding_char); } @@ -557,7 +557,7 @@ fn print_unsigned_oct( let s = match precision { Precision::NotSpecified => format!("{prefix}{num:o}"), Precision::NoNumber => format!("{prefix}{num:o}"), - Precision::Number(p) => format!("{prefix}{num:0>precision$o}", precision = p), + Precision::Number(p) => format!("{prefix}{num:0>p$o}"), }; pad_and_print(&s, flags.left, width, padding_char); } @@ -582,7 +582,7 @@ fn print_unsigned_hex( let s = match precision { Precision::NotSpecified => format!("{prefix}{num:x}"), Precision::NoNumber => format!("{prefix}{num:x}"), - Precision::Number(p) => format!("{prefix}{num:0>precision$x}", precision = p), + Precision::Number(p) => format!("{prefix}{num:0>p$x}"), }; pad_and_print(&s, flags.left, width, padding_char); } @@ -994,7 +994,7 @@ impl Stater { 'R' => { let major = meta.rdev() >> 8; let minor = meta.rdev() & 0xff; - OutputType::Str(format!("{},{}", major, minor)) + OutputType::Str(format!("{major},{minor}")) } 'r' => OutputType::Unsigned(meta.rdev()), 'H' => OutputType::Unsigned(meta.rdev() >> 8), // Major in decimal diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index 2e6a8e26a..3b5c3fb9d 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -170,7 +170,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { 127, format!("{EXEC_ERROR} No such file or directory"), )), - _ => Err(USimpleError::new(1, format!("{EXEC_ERROR} {}", e))), + _ => Err(USimpleError::new(1, format!("{EXEC_ERROR} {e}"))), }; } }; diff --git a/src/uu/uptime/src/uptime.rs b/src/uu/uptime/src/uptime.rs index 05d00f7f8..2508e5196 100644 --- a/src/uu/uptime/src/uptime.rs +++ b/src/uu/uptime/src/uptime.rs @@ -236,7 +236,7 @@ fn default_uptime(matches: &ArgMatches) -> UResult<()> { fn print_loadavg() { match get_formatted_loadavg() { Err(_) => {} - Ok(s) => println!("{}", s), + Ok(s) => println!("{s}"), } } diff --git a/src/uucore/src/lib/features/backup_control.rs b/src/uucore/src/lib/features/backup_control.rs index 4fffc4260..bb02396ed 100644 --- a/src/uucore/src/lib/features/backup_control.rs +++ b/src/uucore/src/lib/features/backup_control.rs @@ -433,7 +433,7 @@ fn numbered_backup_path(path: &Path) -> PathBuf { let file_name = path.file_name().unwrap_or_default(); for i in 1_u64.. { let mut numbered_file_name = file_name.to_os_string(); - numbered_file_name.push(format!(".~{}~", i)); + numbered_file_name.push(format!(".~{i}~")); let path = path.with_file_name(numbered_file_name); if !path.exists() { return path; diff --git a/src/uucore/src/lib/features/buf_copy/common.rs b/src/uucore/src/lib/features/buf_copy/common.rs index 8c74dbb8a..82ae815f3 100644 --- a/src/uucore/src/lib/features/buf_copy/common.rs +++ b/src/uucore/src/lib/features/buf_copy/common.rs @@ -15,8 +15,8 @@ pub enum Error { impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Error::WriteError(msg) => write!(f, "splice() write error: {}", msg), - Error::Io(err) => write!(f, "I/O error: {}", err), + Error::WriteError(msg) => write!(f, "splice() write error: {msg}"), + Error::Io(err) => write!(f, "I/O error: {err}"), } } } diff --git a/src/uucore/src/lib/features/quoting_style.rs b/src/uucore/src/lib/features/quoting_style.rs index 42d39a104..5b838be31 100644 --- a/src/uucore/src/lib/features/quoting_style.rs +++ b/src/uucore/src/lib/features/quoting_style.rs @@ -863,7 +863,7 @@ mod tests { ("????????????????", "shell"), (test_str, "shell-show"), ("'????????????????'", "shell-always"), - (&format!("'{}'", test_str), "shell-always-show"), + (&format!("'{test_str}'"), "shell-always-show"), ( "''$'\\302\\200\\302\\201\\302\\202\\302\\203\\302\\204\\302\\205\\302\\206\\302\\207\\302\\210\\302\\211\\302\\212\\302\\213\\302\\214\\302\\215\\302\\216\\302\\217'", "shell-escape", @@ -893,7 +893,7 @@ mod tests { ("????????????????", "shell"), (test_str, "shell-show"), ("'????????????????'", "shell-always"), - (&format!("'{}'", test_str), "shell-always-show"), + (&format!("'{test_str}'"), "shell-always-show"), ( "''$'\\302\\220\\302\\221\\302\\222\\302\\223\\302\\224\\302\\225\\302\\226\\302\\227\\302\\230\\302\\231\\302\\232\\302\\233\\302\\234\\302\\235\\302\\236\\302\\237'", "shell-escape", diff --git a/src/uucore/src/lib/features/uptime.rs b/src/uucore/src/lib/features/uptime.rs index 9f7f9a8ef..7d9c51fea 100644 --- a/src/uucore/src/lib/features/uptime.rs +++ b/src/uucore/src/lib/features/uptime.rs @@ -308,7 +308,7 @@ pub fn format_nusers(nusers: usize) -> String { match nusers { 0 => "0 user".to_string(), 1 => "1 user".to_string(), - _ => format!("{} users", nusers), + _ => format!("{nusers} users"), } } diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 6204f6f39..e0dff8a26 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -6093,9 +6093,7 @@ fn test_cp_preserve_xattr_readonly_source() { let stdout = String::from_utf8_lossy(&getfattr_output.stdout); assert!( stdout.contains(xattr_key), - "Expected '{}' not found in getfattr output:\n{}", - xattr_key, - stdout + "Expected '{xattr_key}' not found in getfattr output:\n{stdout}" ); at.set_readonly(source_file); diff --git a/tests/by-util/test_csplit.rs b/tests/by-util/test_csplit.rs index 1029344d1..f482299c6 100644 --- a/tests/by-util/test_csplit.rs +++ b/tests/by-util/test_csplit.rs @@ -1457,7 +1457,7 @@ fn create_named_pipe_with_writer(path: &str, data: &str) -> std::process::Child nix::unistd::mkfifo(path, nix::sys::stat::Mode::S_IRWXU).unwrap(); std::process::Command::new("sh") .arg("-c") - .arg(format!("printf '{}' > {path}", data)) + .arg(format!("printf '{data}' > {path}")) .spawn() .unwrap() } diff --git a/tests/by-util/test_head.rs b/tests/by-util/test_head.rs index efba388dc..6c73936f3 100644 --- a/tests/by-util/test_head.rs +++ b/tests/by-util/test_head.rs @@ -435,7 +435,7 @@ fn test_all_but_last_bytes_large_file_piped() { .len(); scene .ucmd() - .args(&["-c", &format!("-{}", seq_19001_20000_file_length)]) + .args(&["-c", &format!("-{seq_19001_20000_file_length}")]) .pipe_in_fixture(seq_20000_file_name) .succeeds() .stdout_only_fixture(seq_19000_file_name); @@ -695,7 +695,7 @@ fn test_validate_stdin_offset_bytes() { .len(); scene .ucmd() - .args(&["-c", &format!("-{}", seq_19001_20000_file_length)]) + .args(&["-c", &format!("-{seq_19001_20000_file_length}")]) .set_stdin(file) .succeeds() .stdout_only_fixture(seq_19000_file_name); diff --git a/tests/test_util_name.rs b/tests/test_util_name.rs index 789077b5c..1ba7ddb91 100644 --- a/tests/test_util_name.rs +++ b/tests/test_util_name.rs @@ -20,7 +20,7 @@ fn init() { std::env::set_var("UUTESTS_BINARY_PATH", TESTS_BINARY); } // Print for debugging - eprintln!("Setting UUTESTS_BINARY_PATH={}", TESTS_BINARY); + eprintln!("Setting UUTESTS_BINARY_PATH={TESTS_BINARY}"); } #[test]