mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-02 00:27:31 +00:00
Inline all format arguments where possible
This makes code more readale and concise, moving all format arguments like `format!("{}", foo)` into the more compact `format!("{foo}")` form. The change was automatically created with, so there are far less change of an accidental typo. ``` cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args ```
This commit is contained in:
parent
1927c2e1d8
commit
e16c76e3c3
180 changed files with 487 additions and 501 deletions
|
@ -53,7 +53,7 @@ fn render(
|
|||
let (call, escaped_call) = match &func_kind {
|
||||
FuncKind::Method(_, Some(receiver)) => (
|
||||
format!("{}.{}", receiver.unescaped(), name.unescaped()).into(),
|
||||
format!("{}.{}", receiver, name).into(),
|
||||
format!("{receiver}.{name}").into(),
|
||||
),
|
||||
_ => (name.unescaped().to_smol_str(), name.to_smol_str()),
|
||||
};
|
||||
|
@ -162,7 +162,7 @@ pub(super) fn add_call_parens<'b>(
|
|||
cov_mark::hit!(inserts_parens_for_function_calls);
|
||||
|
||||
let (snippet, label_suffix) = if self_param.is_none() && params.is_empty() {
|
||||
(format!("{}()$0", escaped_name), "()")
|
||||
(format!("{escaped_name}()$0"), "()")
|
||||
} else {
|
||||
builder.trigger_call_info();
|
||||
let snippet = if let Some(CallableSnippets::FillArguments) = ctx.config.callable {
|
||||
|
@ -174,7 +174,7 @@ pub(super) fn add_call_parens<'b>(
|
|||
let smol_str = n.to_smol_str();
|
||||
let text = smol_str.as_str().trim_start_matches('_');
|
||||
let ref_ = ref_of_param(ctx, text, param.ty());
|
||||
f(&format_args!("${{{}:{}{}}}", index + offset, ref_, text))
|
||||
f(&format_args!("${{{}:{ref_}{text}}}", index + offset))
|
||||
}
|
||||
None => {
|
||||
let name = match param.ty().as_adt() {
|
||||
|
@ -185,7 +185,7 @@ pub(super) fn add_call_parens<'b>(
|
|||
.map(|s| to_lower_snake_case(s.as_str()))
|
||||
.unwrap_or_else(|| "_".to_string()),
|
||||
};
|
||||
f(&format_args!("${{{}:{}}}", index + offset, name))
|
||||
f(&format_args!("${{{}:{name}}}", index + offset))
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -200,12 +200,12 @@ pub(super) fn add_call_parens<'b>(
|
|||
)
|
||||
}
|
||||
None => {
|
||||
format!("{}({})$0", escaped_name, function_params_snippet)
|
||||
format!("{escaped_name}({function_params_snippet})$0")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cov_mark::hit!(suppress_arg_snippets);
|
||||
format!("{}($0)", escaped_name)
|
||||
format!("{escaped_name}($0)")
|
||||
};
|
||||
|
||||
(snippet, "(…)")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue