Use variable names directly in the format strings (#7906)

# Description

Lint: `clippy::uninlined_format_args`

More readable in most situations.
(May be slightly confusing for modifier format strings
https://doc.rust-lang.org/std/fmt/index.html#formatting-parameters)

Alternative to #7865

# User-Facing Changes

None intended

# Tests + Formatting

(Ran `cargo +stable clippy --fix --workspace -- -A clippy::all -D
clippy::uninlined_format_args` to achieve this. Depends on Rust `1.67`)
This commit is contained in:
Stefan Holderbach
2023-01-30 02:37:54 +01:00
committed by GitHub
parent 6ae497eedc
commit ab480856a5
134 changed files with 386 additions and 431 deletions

View File

@ -33,7 +33,7 @@ pub fn ensure_binary_present(package: &str) {
.read_to_string(&mut buffer)
.expect("failed to read cargo build stderr");
if !buffer.is_empty() {
println!("=== cargo build stderr\n{}", buffer);
println!("=== cargo build stderr\n{buffer}");
}
}

View File

@ -95,7 +95,7 @@ impl Executable for Director {
if !commands.is_empty() {
commands.push_str("| ");
}
let _ = writeln!(commands, "{}", pipeline);
let _ = writeln!(commands, "{pipeline}");
}
}
@ -104,7 +104,7 @@ impl Executable for Director {
.stdout(Stdio::piped())
// .stdin(Stdio::piped())
.stderr(Stdio::piped())
.arg(format!("-c '{}'", commands))
.arg(format!("-c '{commands}'"))
.spawn()
.expect("It should be possible to run tests");

View File

@ -49,12 +49,11 @@ impl CheckerMatchers for Play {
None => return Ok(()),
};
let actual =
str::from_utf8(actual).map_err(|_| format!("{} was not utf8 encoded", description))?;
str::from_utf8(actual).map_err(|_| format!("{description} was not utf8 encoded"))?;
if actual != *out {
return Err(format!(
"not equal:\n actual: {}\n expected: {}\n\n",
actual, out
"not equal:\n actual: {actual}\n expected: {out}\n\n"
));
}
@ -77,7 +76,7 @@ impl Matcher<Director> for Play {
impl<'a> Matcher<&'a mut Director> for Play {
fn matches(&self, director: &'a mut Director) -> MatchResult {
if director.executable().is_none() {
return Err(format!("no such process {}", director));
return Err(format!("no such process {director}"));
}
let res = director.execute();
@ -89,7 +88,7 @@ impl<'a> Matcher<&'a mut Director> for Play {
return self.output(out);
}
Err(format!("could not exec process {}: {:?}", director, err))
Err(format!("could not exec process {director}: {err:?}"))
}
}
}