Cleanup format arguments (#2650)

Inlined format args make code more readable, and code more compact.

I ran this clippy command to fix most cases, and then cleaned up a few trailing commas and uncaught edge cases.

```
cargo clippy --bins --examples  --benches --tests --lib --workspace --fix -- -A clippy::all -W clippy::uninlined_format_args
```
This commit is contained in:
Yuri Astrakhan
2023-07-31 22:27:04 +02:00
committed by GitHub
parent 9463b7592f
commit a824e8468c
80 changed files with 270 additions and 307 deletions

View File

@@ -73,7 +73,7 @@ fn ask_to_continue(connect_opts: &ConnectOpts) -> bool {
}
}
Err(e) => {
println!("{}", e);
println!("{e}");
return false;
}
}

View File

@@ -48,7 +48,7 @@ impl MigrationOrdering {
}
fn sequential(version: i64) -> MigrationOrdering {
Self::Sequential(format!("{:04}", version))
Self::Sequential(format!("{version:04}"))
}
fn file_prefix(&self) -> &str {
@@ -149,7 +149,7 @@ pub async fn add(
if !has_existing_migrations {
let quoted_source = if migration_source != "migrations" {
format!("{:?}", migration_source)
format!("{migration_source:?}")
} else {
"".to_string()
};
@@ -178,7 +178,7 @@ See: https://docs.rs/sqlx/0.5/sqlx/macro.migrate.html
fn short_checksum(checksum: &[u8]) -> String {
let mut s = String::with_capacity(checksum.len() * 2);
for b in checksum {
write!(&mut s, "{:02x?}", b).expect("should not fail to write to str");
write!(&mut s, "{b:02x?}").expect("should not fail to write to str");
}
s
}
@@ -341,7 +341,7 @@ pub async fn run(
style(migration.version).cyan(),
style(migration.migration_type.label()).green(),
migration.description,
style(format!("({:?})", elapsed)).dim()
style(format!("({elapsed:?})")).dim()
);
}
}
@@ -431,7 +431,7 @@ pub async fn revert(
style(migration.version).cyan(),
style(migration.migration_type.label()).green(),
migration.description,
style(format!("({:?})", elapsed)).dim()
style(format!("({elapsed:?})")).dim()
);
is_applied = true;
@@ -467,9 +467,8 @@ pub fn build_script(migration_source: &str, force: bool) -> anyhow::Result<()> {
r#"// generated by `sqlx migrate build-script`
fn main() {{
// trigger recompilation when a new migration is added
println!("cargo:rerun-if-changed={}");
println!("cargo:rerun-if-changed={migration_source}");
}}"#,
migration_source
);
fs::write("build.rs", contents)?;

View File

@@ -30,7 +30,7 @@ pub fn add_file(name: &str) -> anyhow::Result<()> {
file.write_all(b"-- Add migration script here")
.context("Could not write to file")?;
println!("Created migration: '{}'", file_name);
println!("Created migration: '{file_name}'");
Ok(())
}
@@ -143,7 +143,7 @@ fn load_migrations() -> anyhow::Result<Vec<Migration>> {
if let Some(ext) = e.path().extension() {
if ext != "sql" {
println!("Wrong ext: {:?}", ext);
println!("Wrong ext: {ext:?}");
continue;
}
} else {

View File

@@ -252,7 +252,7 @@ fn minimal_project_clean(
for file in touch_paths {
let now = filetime::FileTime::now();
filetime::set_file_times(&file, now, now)
.with_context(|| format!("Failed to update mtime for {:?}", file))?;
.with_context(|| format!("Failed to update mtime for {file:?}"))?;
}
// Clean entire packages.