mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
clippy: fix warnings introduced with Rust 1.67.0
This commit is contained in:
@@ -424,7 +424,7 @@ fn get_input_type(path: &str) -> CatResult<InputType> {
|
||||
ft if ft.is_file() => Ok(InputType::File),
|
||||
ft if ft.is_symlink() => Ok(InputType::SymLink),
|
||||
_ => Err(CatError::UnknownFiletype {
|
||||
ft_debug: format!("{:?}", ft),
|
||||
ft_debug: format!("{ft:?}"),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
return Err(r.into());
|
||||
}
|
||||
|
||||
return Err(UUsageError::new(libc::EXIT_FAILURE, format!("{}.\n", r)));
|
||||
return Err(UUsageError::new(libc::EXIT_FAILURE, format!("{r}.\n")));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -67,10 +67,10 @@ impl Error {
|
||||
|
||||
pub(crate) fn report_full_error(mut err: &dyn std::error::Error) -> String {
|
||||
let mut desc = String::with_capacity(256);
|
||||
write!(desc, "{}", err).unwrap();
|
||||
write!(desc, "{err}").unwrap();
|
||||
while let Some(source) = err.source() {
|
||||
err = source;
|
||||
write!(desc, ". {}", err).unwrap();
|
||||
write!(desc, ". {err}").unwrap();
|
||||
}
|
||||
desc
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let modes = matches.get_one::<String>(options::MODE).unwrap(); // should always be Some because required
|
||||
let cmode = if mode_had_minus_prefix {
|
||||
// clap parsing is finished, now put prefix back
|
||||
format!("-{}", modes)
|
||||
format!("-{modes}")
|
||||
} else {
|
||||
modes.to_string()
|
||||
};
|
||||
|
||||
@@ -77,8 +77,8 @@ impl Display for ChrootError {
|
||||
"cannot change root directory to {}: no such directory",
|
||||
s.quote(),
|
||||
),
|
||||
Self::SetGidFailed(s, e) => write!(f, "cannot set gid to {}: {}", s, e),
|
||||
Self::SetGroupsFailed(e) => write!(f, "cannot set groups: {}", e),
|
||||
Self::SetGidFailed(s, e) => write!(f, "cannot set gid to {s}: {e}"),
|
||||
Self::SetGroupsFailed(e) => write!(f, "cannot set groups: {e}"),
|
||||
Self::SetUserFailed(s, e) => {
|
||||
write!(f, "cannot set user to {}: {}", s.maybe_quote(), e)
|
||||
}
|
||||
|
||||
@@ -123,13 +123,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
|
||||
if files.is_empty() {
|
||||
let (crc, size) = cksum("-")?;
|
||||
println!("{} {}", crc, size);
|
||||
println!("{crc} {size}");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
for fname in &files {
|
||||
match cksum(fname.as_ref()).map_err_context(|| format!("{}", fname.maybe_quote())) {
|
||||
Ok((crc, size)) => println!("{} {} {}", crc, size, fname),
|
||||
Ok((crc, size)) => println!("{crc} {size} {fname}"),
|
||||
Err(err) => show!(err),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ pub(crate) fn copy_directory(
|
||||
// the target directory.
|
||||
let context = match Context::new(root, target) {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(format!("failed to get current directory {}", e).into()),
|
||||
Err(e) => return Err(format!("failed to get current directory {e}").into()),
|
||||
};
|
||||
|
||||
// Traverse the contents of the directory, copying each one.
|
||||
|
||||
+3
-4
@@ -746,7 +746,7 @@ impl Options {
|
||||
let recursive = matches.get_flag(options::RECURSIVE) || matches.get_flag(options::ARCHIVE);
|
||||
|
||||
let backup_mode = match backup_control::determine_backup_mode(matches) {
|
||||
Err(e) => return Err(Error::Backup(format!("{}", e))),
|
||||
Err(e) => return Err(Error::Backup(format!("{e}"))),
|
||||
Ok(mode) => mode,
|
||||
};
|
||||
|
||||
@@ -865,8 +865,7 @@ impl Options {
|
||||
"never" => SparseMode::Never,
|
||||
_ => {
|
||||
return Err(Error::InvalidArgument(format!(
|
||||
"invalid argument {} for \'sparse\'",
|
||||
val
|
||||
"invalid argument {val} for \'sparse\'"
|
||||
)));
|
||||
}
|
||||
}
|
||||
@@ -1857,7 +1856,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_aligned_ancestors() {
|
||||
let actual = aligned_ancestors(&Path::new("a/b/c"), &Path::new("d/a/b/c"));
|
||||
let actual = aligned_ancestors(Path::new("a/b/c"), Path::new("d/a/b/c"));
|
||||
let expected = vec![
|
||||
(Path::new("a"), Path::new("d/a")),
|
||||
(Path::new("a/b"), Path::new("d/a/b")),
|
||||
|
||||
@@ -69,9 +69,7 @@ pub(crate) fn copy_on_write(
|
||||
// support COW).
|
||||
match reflink_mode {
|
||||
ReflinkMode::Always => {
|
||||
return Err(
|
||||
format!("failed to clone {:?} from {:?}: {}", source, dest, error).into(),
|
||||
)
|
||||
return Err(format!("failed to clone {source:?} from {dest:?}: {error}").into())
|
||||
}
|
||||
_ => {
|
||||
if source_is_fifo {
|
||||
|
||||
+14
-14
@@ -574,7 +574,7 @@ mod tests {
|
||||
assert_eq!(input_splitter.add_line_to_buffer(0, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 1);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
@@ -583,7 +583,7 @@ mod tests {
|
||||
assert_eq!(input_splitter.add_line_to_buffer(1, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 2);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
@@ -595,7 +595,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(input_splitter.buffer_len(), 2);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
input_splitter.rewind_buffer();
|
||||
@@ -605,7 +605,7 @@ mod tests {
|
||||
assert_eq!(line, String::from("bbb"));
|
||||
assert_eq!(input_splitter.buffer_len(), 1);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
@@ -613,7 +613,7 @@ mod tests {
|
||||
assert_eq!(line, String::from("ccc"));
|
||||
assert_eq!(input_splitter.buffer_len(), 0);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
@@ -621,7 +621,7 @@ mod tests {
|
||||
assert_eq!(line, String::from("ddd"));
|
||||
assert_eq!(input_splitter.buffer_len(), 0);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
assert!(input_splitter.next().is_none());
|
||||
@@ -646,7 +646,7 @@ mod tests {
|
||||
assert_eq!(input_splitter.add_line_to_buffer(0, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 1);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
@@ -655,7 +655,7 @@ mod tests {
|
||||
assert_eq!(input_splitter.add_line_to_buffer(1, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 2);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
@@ -664,7 +664,7 @@ mod tests {
|
||||
assert_eq!(input_splitter.add_line_to_buffer(2, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 3);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
input_splitter.rewind_buffer();
|
||||
@@ -675,7 +675,7 @@ mod tests {
|
||||
assert_eq!(input_splitter.add_line_to_buffer(0, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 3);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
@@ -683,7 +683,7 @@ mod tests {
|
||||
assert_eq!(line, String::from("aaa"));
|
||||
assert_eq!(input_splitter.buffer_len(), 2);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
@@ -691,7 +691,7 @@ mod tests {
|
||||
assert_eq!(line, String::from("bbb"));
|
||||
assert_eq!(input_splitter.buffer_len(), 1);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
@@ -699,7 +699,7 @@ mod tests {
|
||||
assert_eq!(line, String::from("ccc"));
|
||||
assert_eq!(input_splitter.buffer_len(), 0);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
@@ -707,7 +707,7 @@ mod tests {
|
||||
assert_eq!(line, String::from("ddd"));
|
||||
assert_eq!(input_splitter.buffer_len(), 0);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
assert!(input_splitter.next().is_none());
|
||||
|
||||
@@ -224,35 +224,35 @@ mod tests {
|
||||
assert_eq!(patterns.len(), 5);
|
||||
match patterns.get(0) {
|
||||
Some(Pattern::UpToMatch(reg, 0, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test1.*end$");
|
||||
}
|
||||
_ => panic!("expected UpToMatch pattern"),
|
||||
};
|
||||
match patterns.get(1) {
|
||||
Some(Pattern::UpToMatch(reg, 0, ExecutePattern::Always)) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test2.*end$");
|
||||
}
|
||||
_ => panic!("expected UpToMatch pattern"),
|
||||
};
|
||||
match patterns.get(2) {
|
||||
Some(Pattern::UpToMatch(reg, 0, ExecutePattern::Times(5))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test3.*end$");
|
||||
}
|
||||
_ => panic!("expected UpToMatch pattern"),
|
||||
};
|
||||
match patterns.get(3) {
|
||||
Some(Pattern::UpToMatch(reg, 3, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test4.*end$");
|
||||
}
|
||||
_ => panic!("expected UpToMatch pattern"),
|
||||
};
|
||||
match patterns.get(4) {
|
||||
Some(Pattern::UpToMatch(reg, -3, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test5.*end$");
|
||||
}
|
||||
_ => panic!("expected UpToMatch pattern"),
|
||||
@@ -277,35 +277,35 @@ mod tests {
|
||||
assert_eq!(patterns.len(), 5);
|
||||
match patterns.get(0) {
|
||||
Some(Pattern::SkipToMatch(reg, 0, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test1.*end$");
|
||||
}
|
||||
_ => panic!("expected SkipToMatch pattern"),
|
||||
};
|
||||
match patterns.get(1) {
|
||||
Some(Pattern::SkipToMatch(reg, 0, ExecutePattern::Always)) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test2.*end$");
|
||||
}
|
||||
_ => panic!("expected SkipToMatch pattern"),
|
||||
};
|
||||
match patterns.get(2) {
|
||||
Some(Pattern::SkipToMatch(reg, 0, ExecutePattern::Times(5))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test3.*end$");
|
||||
}
|
||||
_ => panic!("expected SkipToMatch pattern"),
|
||||
};
|
||||
match patterns.get(3) {
|
||||
Some(Pattern::SkipToMatch(reg, 3, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test4.*end$");
|
||||
}
|
||||
_ => panic!("expected SkipToMatch pattern"),
|
||||
};
|
||||
match patterns.get(4) {
|
||||
Some(Pattern::SkipToMatch(reg, -3, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test5.*end$");
|
||||
}
|
||||
_ => panic!("expected SkipToMatch pattern"),
|
||||
|
||||
@@ -42,9 +42,7 @@ impl SplitName {
|
||||
.unwrap_or(2);
|
||||
// translate the custom format into a function
|
||||
let fn_split_name: Box<dyn Fn(usize) -> String> = match format_opt {
|
||||
None => Box::new(move |n: usize| -> String {
|
||||
format!("{}{:0width$}", prefix, n, width = n_digits)
|
||||
}),
|
||||
None => Box::new(move |n: usize| -> String { format!("{prefix}{n:0n_digits$}") }),
|
||||
Some(custom) => {
|
||||
let spec =
|
||||
Regex::new(r"(?P<ALL>%((?P<FLAG>[0#-])(?P<WIDTH>\d+)?)?(?P<TYPE>[diuoxX]))")
|
||||
@@ -62,16 +60,16 @@ impl SplitName {
|
||||
match (captures.name("FLAG"), captures.name("TYPE")) {
|
||||
(None, Some(ref t)) => match t.as_str() {
|
||||
"d" | "i" | "u" => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n}{after}")
|
||||
}),
|
||||
"o" => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:o}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:o}{after}")
|
||||
}),
|
||||
"x" => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:x}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:x}{after}")
|
||||
}),
|
||||
"X" => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:X}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:X}{after}")
|
||||
}),
|
||||
_ => return Err(CsplitError::SuffixFormatIncorrect),
|
||||
},
|
||||
@@ -82,19 +80,19 @@ impl SplitName {
|
||||
*/
|
||||
// decimal
|
||||
("0", "d" | "i" | "u") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:0width$}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:0width$}{after}")
|
||||
}),
|
||||
// octal
|
||||
("0", "o") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:0width$o}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:0width$o}{after}")
|
||||
}),
|
||||
// lower hexadecimal
|
||||
("0", "x") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:0width$x}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:0width$x}{after}")
|
||||
}),
|
||||
// upper hexadecimal
|
||||
("0", "X") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:0width$X}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:0width$X}{after}")
|
||||
}),
|
||||
|
||||
/*
|
||||
@@ -102,15 +100,15 @@ impl SplitName {
|
||||
*/
|
||||
// octal
|
||||
("#", "o") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:>#width$o}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:>#width$o}{after}")
|
||||
}),
|
||||
// lower hexadecimal
|
||||
("#", "x") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:>#width$x}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:>#width$x}{after}")
|
||||
}),
|
||||
// upper hexadecimal
|
||||
("#", "X") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:>#width$X}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:>#width$X}{after}")
|
||||
}),
|
||||
|
||||
/*
|
||||
@@ -118,19 +116,19 @@ impl SplitName {
|
||||
*/
|
||||
// decimal
|
||||
("-", "d" | "i" | "u") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:<#width$}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:<#width$}{after}")
|
||||
}),
|
||||
// octal
|
||||
("-", "o") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:<#width$o}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:<#width$o}{after}")
|
||||
}),
|
||||
// lower hexadecimal
|
||||
("-", "x") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:<#width$x}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:<#width$x}{after}")
|
||||
}),
|
||||
// upper hexadecimal
|
||||
("-", "X") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:<#width$X}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:<#width$X}{after}")
|
||||
}),
|
||||
|
||||
_ => return Err(CsplitError::SuffixFormatIncorrect),
|
||||
|
||||
@@ -117,7 +117,7 @@ impl<'a> From<&'a str> for Iso8601Format {
|
||||
NS => Self::Ns,
|
||||
DATE => Self::Date,
|
||||
// Should be caught by clap
|
||||
_ => panic!("Invalid format: {}", s),
|
||||
_ => panic!("Invalid format: {s}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ impl<'a> From<&'a str> for Rfc3339Format {
|
||||
SECONDS | SECOND => Self::Seconds,
|
||||
NS => Self::Ns,
|
||||
// Should be caught by clap
|
||||
_ => panic!("Invalid format: {}", s),
|
||||
_ => panic!("Invalid format: {s}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,7 +257,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
.format_with_items(format_items)
|
||||
.to_string()
|
||||
.replace("%f", "%N");
|
||||
println!("{}", formatted);
|
||||
println!("{formatted}");
|
||||
}
|
||||
Err((input, _err)) => show_error!("invalid date {}", input.quote()),
|
||||
}
|
||||
|
||||
+1
-3
@@ -772,9 +772,7 @@ fn is_stdout_redirected_to_seekable_file() -> bool {
|
||||
let p = Path::new(&s);
|
||||
match File::open(p) {
|
||||
Ok(mut f) => {
|
||||
f.seek(SeekFrom::Current(0)).is_ok()
|
||||
&& f.seek(SeekFrom::End(0)).is_ok()
|
||||
&& f.seek(SeekFrom::Start(0)).is_ok()
|
||||
f.stream_position().is_ok() && f.seek(SeekFrom::End(0)).is_ok() && f.rewind().is_ok()
|
||||
}
|
||||
Err(_) => false,
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ pub(crate) fn to_magnitude_and_suffix(n: u128, suffix_type: SuffixType) -> Strin
|
||||
//
|
||||
let quotient = (n as f64) / (base as f64);
|
||||
if quotient < 10.0 {
|
||||
format!("{:.1} {}", quotient, suffix)
|
||||
format!("{quotient:.1} {suffix}")
|
||||
} else {
|
||||
format!("{} {}", quotient.round(), suffix)
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ impl std::fmt::Display for ParseError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::UnrecognizedOperand(arg) => {
|
||||
write!(f, "Unrecognized operand '{}'", arg)
|
||||
write!(f, "Unrecognized operand '{arg}'")
|
||||
}
|
||||
Self::MultipleFmtTable => {
|
||||
write!(
|
||||
@@ -421,32 +421,31 @@ impl std::fmt::Display for ParseError {
|
||||
)
|
||||
}
|
||||
Self::ConvFlagNoMatch(arg) => {
|
||||
write!(f, "Unrecognized conv=CONV -> {}", arg)
|
||||
write!(f, "Unrecognized conv=CONV -> {arg}")
|
||||
}
|
||||
Self::MultiplierStringParseFailure(arg) => {
|
||||
write!(f, "Unrecognized byte multiplier -> {}", arg)
|
||||
write!(f, "Unrecognized byte multiplier -> {arg}")
|
||||
}
|
||||
Self::MultiplierStringOverflow(arg) => {
|
||||
write!(
|
||||
f,
|
||||
"Multiplier string would overflow on current system -> {}",
|
||||
arg
|
||||
"Multiplier string would overflow on current system -> {arg}"
|
||||
)
|
||||
}
|
||||
Self::BlockUnblockWithoutCBS => {
|
||||
write!(f, "conv=block or conv=unblock specified without cbs=N")
|
||||
}
|
||||
Self::StatusLevelNotRecognized(arg) => {
|
||||
write!(f, "status=LEVEL not recognized -> {}", arg)
|
||||
write!(f, "status=LEVEL not recognized -> {arg}")
|
||||
}
|
||||
Self::BsOutOfRange(arg) => {
|
||||
write!(f, "{}=N cannot fit into memory", arg)
|
||||
write!(f, "{arg}=N cannot fit into memory")
|
||||
}
|
||||
Self::Unimplemented(arg) => {
|
||||
write!(f, "feature not implemented on this system -> {}", arg)
|
||||
write!(f, "feature not implemented on this system -> {arg}")
|
||||
}
|
||||
Self::InvalidNumber(arg) => {
|
||||
write!(f, "invalid number: ‘{}’", arg)
|
||||
write!(f, "invalid number: ‘{arg}’")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,29 +56,28 @@ fn unimplemented_flags_should_error() {
|
||||
|
||||
// The following flags are not implemented
|
||||
for flag in ["cio", "nocache", "nolinks", "text", "binary"] {
|
||||
let args = vec![format!("iflag={}", flag)];
|
||||
let args = vec![format!("iflag={flag}")];
|
||||
|
||||
if Parser::new()
|
||||
.parse(&args.iter().map(AsRef::as_ref).collect::<Vec<_>>()[..])
|
||||
.is_ok()
|
||||
{
|
||||
succeeded.push(format!("iflag={}", flag));
|
||||
succeeded.push(format!("iflag={flag}"));
|
||||
}
|
||||
|
||||
let args = vec![format!("oflag={}", flag)];
|
||||
let args = vec![format!("oflag={flag}")];
|
||||
|
||||
if Parser::new()
|
||||
.parse(&args.iter().map(AsRef::as_ref).collect::<Vec<_>>()[..])
|
||||
.is_ok()
|
||||
{
|
||||
succeeded.push(format!("iflag={}", flag));
|
||||
succeeded.push(format!("iflag={flag}"));
|
||||
}
|
||||
}
|
||||
|
||||
assert!(
|
||||
succeeded.is_empty(),
|
||||
"The following flags did not panic as expected: {:?}",
|
||||
succeeded
|
||||
"The following flags did not panic as expected: {succeeded:?}"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ impl ProgUpdate {
|
||||
match self.read_stat.records_truncated {
|
||||
0 => {}
|
||||
1 => writeln!(w, "1 truncated record")?,
|
||||
n => writeln!(w, "{} truncated records", n)?,
|
||||
n => writeln!(w, "{n} truncated records")?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -154,29 +154,19 @@ impl ProgUpdate {
|
||||
match btotal {
|
||||
1 => write!(
|
||||
w,
|
||||
"{}{} byte copied, {:.1} s, {}/s{}",
|
||||
carriage_return, btotal, duration, transfer_rate, newline,
|
||||
"{carriage_return}{btotal} byte copied, {duration:.1} s, {transfer_rate}/s{newline}",
|
||||
),
|
||||
0..=999 => write!(
|
||||
w,
|
||||
"{}{} bytes copied, {:.1} s, {}/s{}",
|
||||
carriage_return, btotal, duration, transfer_rate, newline,
|
||||
"{carriage_return}{btotal} bytes copied, {duration:.1} s, {transfer_rate}/s{newline}",
|
||||
),
|
||||
1000..=1023 => write!(
|
||||
w,
|
||||
"{}{} bytes ({}) copied, {:.1} s, {}/s{}",
|
||||
carriage_return, btotal, btotal_metric, duration, transfer_rate, newline,
|
||||
"{carriage_return}{btotal} bytes ({btotal_metric}) copied, {duration:.1} s, {transfer_rate}/s{newline}",
|
||||
),
|
||||
_ => write!(
|
||||
w,
|
||||
"{}{} bytes ({}, {}) copied, {:.1} s, {}/s{}",
|
||||
carriage_return,
|
||||
btotal,
|
||||
btotal_metric,
|
||||
btotal_bin,
|
||||
duration,
|
||||
transfer_rate,
|
||||
newline,
|
||||
"{carriage_return}{btotal} bytes ({btotal_metric}, {btotal_bin}) copied, {duration:.1} s, {transfer_rate}/s{newline}",
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -455,10 +445,7 @@ pub(crate) fn gen_prog_updater(
|
||||
|
||||
register_linux_signal_handler(sigval.clone()).unwrap_or_else(|e| {
|
||||
if Some(StatusLevel::None) != print_level {
|
||||
eprintln!(
|
||||
"Internal dd Warning: Unable to register signal handler \n\t{}",
|
||||
e
|
||||
);
|
||||
eprintln!("Internal dd Warning: Unable to register signal handler \n\t{e}");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -91,12 +91,12 @@ pub(crate) fn to_magnitude_and_suffix(n: u128, suffix_type: SuffixType) -> Strin
|
||||
let suffix = suffixes[i];
|
||||
|
||||
if rem == 0 {
|
||||
format!("{}{}", quot, suffix)
|
||||
format!("{quot}{suffix}")
|
||||
} else {
|
||||
let tenths_place = rem / (bases[i] / 10);
|
||||
|
||||
if rem % (bases[i] / 10) == 0 {
|
||||
format!("{}.{}{}", quot, tenths_place, suffix)
|
||||
format!("{quot}.{tenths_place}{suffix}")
|
||||
} else if tenths_place + 1 == 10 || quot >= 10 {
|
||||
format!("{}{}", quot + 1, suffix)
|
||||
} else {
|
||||
@@ -205,7 +205,7 @@ impl fmt::Display for BlockSize {
|
||||
to_magnitude_and_suffix(*n as u128, SuffixType::Si)
|
||||
};
|
||||
|
||||
write!(f, "{}", s)
|
||||
write!(f, "{s}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -146,10 +146,10 @@ impl fmt::Display for OptionsError {
|
||||
}
|
||||
// TODO This needs to vary based on whether `--block-size`
|
||||
// or `-B` were provided.
|
||||
Self::InvalidBlockSize(s) => write!(f, "invalid --block-size argument {}", s),
|
||||
Self::InvalidBlockSize(s) => write!(f, "invalid --block-size argument {s}"),
|
||||
// TODO This needs to vary based on whether `--block-size`
|
||||
// or `-B` were provided.
|
||||
Self::InvalidSuffix(s) => write!(f, "invalid suffix in --block-size argument {}", s),
|
||||
Self::InvalidSuffix(s) => write!(f, "invalid suffix in --block-size argument {s}"),
|
||||
Self::ColumnError(ColumnError::MultipleColumns(s)) => write!(
|
||||
f,
|
||||
"option --output: field {} used more than once",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user