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:
Yuri Astrakhan 2022-12-23 13:42:58 -05:00
parent 1927c2e1d8
commit e16c76e3c3
180 changed files with 487 additions and 501 deletions

View file

@ -81,7 +81,7 @@ pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext<'
acc.add_group(
&GroupLabel("Generate delegate methods…".to_owned()),
AssistId("generate_delegate_methods", AssistKind::Generate),
format!("Generate delegate for `{}.{}()`", field_name, method.name(ctx.db())),
format!("Generate delegate for `{field_name}.{}()`", method.name(ctx.db())),
target,
|builder| {
// Create the function

View file

@ -157,7 +157,7 @@ fn generate_enum_projection_method(
assist_description,
target,
|builder| {
let vis = parent_enum.visibility().map_or(String::new(), |v| format!("{} ", v));
let vis = parent_enum.visibility().map_or(String::new(), |v| format!("{v} "));
let field_type_syntax = field_type.syntax();

View file

@ -235,7 +235,7 @@ fn generate_getter_from_info(
) -> String {
let mut buf = String::with_capacity(512);
let vis = info.strukt.visibility().map_or(String::new(), |v| format!("{} ", v));
let vis = info.strukt.visibility().map_or(String::new(), |v| format!("{v} "));
let (ty, body) = if info.mutable {
(
format!("&mut {}", record_field_info.field_ty),

View file

@ -171,7 +171,7 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult<'_>, assist_la
}
FileSystemEdit::MoveDir { src, src_id, dst } => {
// temporary placeholder for MoveDir since we are not using MoveDir in ide assists yet.
(dst, format!("{:?}\n{:?}", src_id, src))
(dst, format!("{src_id:?}\n{src:?}"))
}
};
let sr = db.file_source_root(dst.anchor);

View file

@ -18,7 +18,7 @@ use super::check_doc_test;
for assist in assists.iter() {
for (idx, section) in assist.sections.iter().enumerate() {
let test_id =
if idx == 0 { assist.id.clone() } else { format!("{}_{}", &assist.id, idx) };
if idx == 0 { assist.id.clone() } else { format!("{}_{idx}", &assist.id) };
let test = format!(
r######"
#[test]
@ -175,7 +175,7 @@ impl fmt::Display for Assist {
fn hide_hash_comments(text: &str) -> String {
text.split('\n') // want final newline
.filter(|&it| !(it.starts_with("# ") || it == "#"))
.map(|it| format!("{}\n", it))
.map(|it| format!("{it}\n"))
.collect()
}
@ -190,6 +190,6 @@ fn reveal_hash_comments(text: &str) -> String {
it
}
})
.map(|it| format!("{}\n", it))
.map(|it| format!("{it}\n"))
.collect()
}