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

@ -63,7 +63,7 @@ impl Command for PluginDeclaration {
let decl = engine_state.get_decl(call.decl_id);
ShellError::GenericError(
format!("Unable to spawn plugin for {}", decl.name()),
format!("{}", err),
format!("{err}"),
Some(call.head),
None,
Vec::new(),
@ -87,7 +87,7 @@ impl Command for PluginDeclaration {
"Plugin {} can not handle the custom value {}",
self.name, custom_value_name
),
format!("custom value {}", custom_value_name),
format!("custom value {custom_value_name}"),
Some(span),
None,
Vec::new(),

View File

@ -130,11 +130,11 @@ pub fn get_signature(
format!("Can't find {prog_name}, please make sure that {prog_name} is in PATH.")
}
_ => {
format!("Error spawning child process: {}", err)
format!("Error spawning child process: {err}")
}
},
_ => {
format!("Error spawning child process: {}", err)
format!("Error spawning child process: {err}")
}
};
@ -173,7 +173,7 @@ pub fn get_signature(
match child.wait() {
Ok(_) => Ok(signatures),
Err(err) => Err(ShellError::PluginFailedToLoad(format!("{}", err))),
Err(err) => Err(ShellError::PluginFailedToLoad(format!("{err}"))),
}
}
@ -319,7 +319,7 @@ fn print_help(plugin: &mut impl Plugin, encoder: impl PluginEncoder) {
})
.and_then(|_| {
let flags = get_flags_section(signature);
write!(help, "{}", flags)
write!(help, "{flags}")
})
.and_then(|_| writeln!(help, "\nParameters:"))
.and_then(|_| {
@ -360,11 +360,11 @@ fn print_help(plugin: &mut impl Plugin, encoder: impl PluginEncoder) {
.and_then(|_| writeln!(help, "======================"));
if res.is_err() {
println!("{:?}", res)
println!("{res:?}")
}
});
println!("{}", help)
println!("{help}")
}
pub fn get_plugin_encoding(child_stdout: &mut ChildStdout) -> Result<EncodingType, ShellError> {

View File

@ -60,13 +60,13 @@ impl From<ShellError> for LabeledError {
LabeledError { label, msg, span }
}
ShellError::CantConvert(expected, input, span, _help) => LabeledError {
label: format!("Can't convert to {}", expected),
msg: format!("can't convert {} to {}", expected, input),
label: format!("Can't convert to {expected}"),
msg: format!("can't convert {expected} to {input}"),
span: Some(span),
},
ShellError::DidYouMean(suggestion, span) => LabeledError {
label: "Name not found".into(),
msg: format!("did you mean '{}'", suggestion),
msg: format!("did you mean '{suggestion}'"),
span: Some(span),
},
ShellError::PluginFailedToLoad(msg) => LabeledError {

View File

@ -56,7 +56,7 @@ impl CustomValue for PluginCustomValue {
"Unable to spawn plugin for {} to get base value",
self.source
),
format!("{}", err),
format!("{err}"),
Some(span),
None,
Vec::new(),
@ -85,7 +85,7 @@ impl CustomValue for PluginCustomValue {
"Unable to decode call for {} to get base value",
self.source
),
format!("{}", err),
format!("{err}"),
Some(span),
None,
Vec::new(),