forked from extern/nushell
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:
committed by
GitHub
parent
6ae497eedc
commit
ab480856a5
@ -23,18 +23,18 @@ pub fn escape_for_script_arg(input: &str) -> String {
|
||||
if let Some((arg_name, arg_val)) = input.split_once('=') {
|
||||
// only want to escape arg_val.
|
||||
let arg_val = if arg_val.contains(' ') {
|
||||
format!("`{}`", arg_val)
|
||||
format!("`{arg_val}`")
|
||||
} else if arg_val.contains('"') || arg_val.contains('\\') {
|
||||
escape_quote_string(arg_val)
|
||||
} else {
|
||||
arg_val.into()
|
||||
};
|
||||
return format!("{}={}", arg_name, arg_val);
|
||||
return format!("{arg_name}={arg_val}");
|
||||
}
|
||||
}
|
||||
|
||||
if input.contains(' ') {
|
||||
format!("`{}`", input)
|
||||
format!("`{input}`")
|
||||
} else if input.contains('"') || input.contains('\\') {
|
||||
escape_quote_string(input)
|
||||
} else {
|
||||
|
@ -36,7 +36,7 @@ pub fn eval_constant(
|
||||
// TODO: Better error conversion
|
||||
Err(shell_error) => Err(ParseError::LabeledError(
|
||||
"Error when following cell path".to_string(),
|
||||
format!("{:?}", shell_error),
|
||||
format!("{shell_error:?}"),
|
||||
expr.span,
|
||||
)),
|
||||
}
|
||||
|
@ -3561,7 +3561,7 @@ pub fn parse_register(
|
||||
Ok(path)
|
||||
} else {
|
||||
Err(ParseError::RegisteredFileNotFound(
|
||||
format!("{:?}", path),
|
||||
format!("{path:?}"),
|
||||
expr.span,
|
||||
))
|
||||
}
|
||||
@ -3576,7 +3576,7 @@ pub fn parse_register(
|
||||
serde_json::from_slice::<Signature>(signature).map_err(|e| {
|
||||
ParseError::LabeledError(
|
||||
"Signature deserialization error".into(),
|
||||
format!("unable to deserialize signature: {}", e),
|
||||
format!("unable to deserialize signature: {e}"),
|
||||
spans[0],
|
||||
)
|
||||
})
|
||||
@ -3597,7 +3597,7 @@ pub fn parse_register(
|
||||
Ok(path)
|
||||
} else {
|
||||
Err(ParseError::RegisteredFileNotFound(
|
||||
format!("{:?}", path),
|
||||
format!("{path:?}"),
|
||||
expr.span,
|
||||
))
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ pub fn check_name<'a>(
|
||||
Some((
|
||||
&spans[command_len],
|
||||
ParseError::AssignmentMismatch(
|
||||
format!("{} missing name", name),
|
||||
format!("{name} missing name"),
|
||||
"missing name".into(),
|
||||
spans[command_len],
|
||||
),
|
||||
@ -251,7 +251,7 @@ pub fn check_name<'a>(
|
||||
Some((
|
||||
&spans[command_len + 1],
|
||||
ParseError::AssignmentMismatch(
|
||||
format!("{} missing sign", name),
|
||||
format!("{name} missing sign"),
|
||||
"missing equal sign".into(),
|
||||
spans[command_len + 1],
|
||||
),
|
||||
@ -673,7 +673,7 @@ pub fn parse_multispan_value(
|
||||
(
|
||||
Expression::garbage(span),
|
||||
Some(ParseError::Expected(
|
||||
format!("one of a list of accepted shapes: {:?}", shapes),
|
||||
format!("one of a list of accepted shapes: {shapes:?}"),
|
||||
span,
|
||||
)),
|
||||
)
|
||||
@ -3668,7 +3668,7 @@ pub fn parse_signature_helper(
|
||||
error = error.or_else(|| {
|
||||
Some(ParseError::AssignmentMismatch(
|
||||
"Default value wrong type".into(),
|
||||
format!("default value not {}", t),
|
||||
format!("default value not {t}"),
|
||||
expression.span,
|
||||
))
|
||||
})
|
||||
@ -3717,8 +3717,7 @@ pub fn parse_signature_helper(
|
||||
"Default value is the wrong type"
|
||||
.into(),
|
||||
format!(
|
||||
"default value should be {}",
|
||||
t
|
||||
"default value should be {t}"
|
||||
),
|
||||
expression_span,
|
||||
))
|
||||
@ -4428,7 +4427,7 @@ pub fn parse_value(
|
||||
return (
|
||||
Expression::garbage(span),
|
||||
Some(ParseError::Expected(
|
||||
format!("non-block value: {}", shape),
|
||||
format!("non-block value: {shape}"),
|
||||
span,
|
||||
)),
|
||||
);
|
||||
|
Reference in New Issue
Block a user