From 553258af51034bc84dc9f951201e7b8f2285b57e Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 25 Jul 2024 15:35:58 -0700 Subject: [PATCH 1/5] Have clippy warn about uninlined format arguments This makes clippy warn about `format!("{}", var)`, with a machine-applicable fix converting to `format!("{var}")`. --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 90d89f6e..97c7ed79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,6 +80,7 @@ string_lit_as_bytes = "warn" string_to_string = "warn" todo = "warn" trait_duplication_in_bounds = "warn" +uninlined_format_args = "warn" verbose_file_reads = "warn" wildcard_imports = "warn" zero_sized_map_values = "warn" From 7a28f01acfe8eb95f4e54127e1b66aa31cf2aeed Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 23 Aug 2024 19:02:02 -0500 Subject: [PATCH 2/5] docs(contrib): Fix tpo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 87d9134e..b0318b82 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,7 @@ We ask that commits are atomic, meaning they are complete and have a single resp PRs should tell a cohesive story, with test and refactor commits that keep the fix or feature commits simple and clear. -Specifically, we would encouage +Specifically, we would encourage - File renames be isolated into their own commit - Add tests in a commit before their feature or fix, showing the current behavior. The diff for the feature/fix commit will then show how the behavior changed, From 37cf1085bc6aa53e18a37f0aa97be51afa6e7f14 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 01:02:47 +0000 Subject: [PATCH 3/5] chore(deps): Update EmbarkStudios/cargo-deny-action action to v2 --- .github/workflows/audit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 07c70eeb..a94be159 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -47,7 +47,7 @@ jobs: - bans licenses sources steps: - uses: actions/checkout@v4 - - uses: EmbarkStudios/cargo-deny-action@v1 + - uses: EmbarkStudios/cargo-deny-action@v2 with: command: check ${{ matrix.checks }} rust-version: stable From 6e193aa09aed80118df4e1317b8eed057bad6f0b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 26 Sep 2024 20:59:12 -0500 Subject: [PATCH 4/5] chore: Ensure pre-commit gets non-system Python This is needed with the ubuntu-24.04 images so that `setup-python` will install a version of Python that the pre-commit action can install into. See pre-commit/action#210 for more of an analysis of this. --- .github/workflows/pre-commit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 1b000abf..7b55a3d9 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -24,4 +24,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + with: + python-version: '3.x' - uses: pre-commit/action@v3.0.1 From cbb6c28fd0c57f6488ec3bfcc9188772519d2256 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 27 Sep 2024 13:28:35 -0500 Subject: [PATCH 5/5] style: Inline fmt args --- crates/benchmarks/benches/linear.rs | 2 +- crates/toml/examples/decode.rs | 2 +- crates/toml/examples/enum_external.rs | 2 +- crates/toml/examples/toml2json.rs | 2 +- crates/toml/src/ser.rs | 4 ++-- crates/toml/src/value.rs | 9 ++++----- crates/toml/tests/testsuite/spanned.rs | 2 +- crates/toml_datetime/src/datetime.rs | 8 ++++---- crates/toml_edit/examples/visit.rs | 4 ++-- crates/toml_edit/src/array.rs | 4 ++-- crates/toml_edit/src/de/table_enum.rs | 8 ++++---- crates/toml_edit/src/encode.rs | 8 ++++---- crates/toml_edit/src/error.rs | 10 +++------- crates/toml_edit/src/parser/error.rs | 9 ++++----- crates/toml_edit/src/parser/mod.rs | 12 +++--------- crates/toml_edit/src/parser/numbers.rs | 2 +- crates/toml_edit/src/parser/trivia.rs | 2 +- crates/toml_edit/src/raw_string.rs | 18 +++++++++--------- crates/toml_edit/src/repr.rs | 4 ++-- crates/toml_edit/tests/testsuite/datetime.rs | 2 +- crates/toml_edit/tests/testsuite/parse.rs | 2 +- 21 files changed, 52 insertions(+), 64 deletions(-) diff --git a/crates/benchmarks/benches/linear.rs b/crates/benchmarks/benches/linear.rs index e11636af..47b47e57 100644 --- a/crates/benchmarks/benches/linear.rs +++ b/crates/benchmarks/benches/linear.rs @@ -32,7 +32,7 @@ mod map { fn gen(num_entries: usize) -> String { let mut s = String::new(); for i in 0..num_entries { - s += &format!("[header_no_{}]\n", i); + s += &format!("[header_no_{i}]\n"); s += "entry = 42\n"; } s diff --git a/crates/toml/examples/decode.rs b/crates/toml/examples/decode.rs index 348e9116..f09eec68 100644 --- a/crates/toml/examples/decode.rs +++ b/crates/toml/examples/decode.rs @@ -50,5 +50,5 @@ fn main() { "#; let decoded: Config = toml::from_str(toml_str).unwrap(); - println!("{:#?}", decoded); + println!("{decoded:#?}"); } diff --git a/crates/toml/examples/enum_external.rs b/crates/toml/examples/enum_external.rs index edac7d6e..5c95fde1 100644 --- a/crates/toml/examples/enum_external.rs +++ b/crates/toml/examples/enum_external.rs @@ -41,5 +41,5 @@ fn main() { ]"#; let decoded: Config = toml::from_str(toml_str).unwrap(); - println!("{:#?}", decoded); + println!("{decoded:#?}"); } diff --git a/crates/toml/examples/toml2json.rs b/crates/toml/examples/toml2json.rs index 56a912c9..2ae96289 100644 --- a/crates/toml/examples/toml2json.rs +++ b/crates/toml/examples/toml2json.rs @@ -21,7 +21,7 @@ fn main() { let json = convert(toml); println!("{}", serde_json::to_string_pretty(&json).unwrap()); } - Err(error) => println!("failed to parse TOML: {}", error), + Err(error) => println!("failed to parse TOML: {error}"), } } diff --git a/crates/toml/src/ser.rs b/crates/toml/src/ser.rs index b64271a1..955e243b 100644 --- a/crates/toml/src/ser.rs +++ b/crates/toml/src/ser.rs @@ -915,7 +915,7 @@ mod internal { settings.visit_table_mut(&mut table); let doc: toml_edit::DocumentMut = table.into(); - write!(dst, "{}", doc).unwrap(); + write!(dst, "{doc}").unwrap(); Ok(()) } @@ -1067,7 +1067,7 @@ mod internal { let value = value.map_err(Error::wrap)?; - write!(dst, "{}", value).unwrap(); + write!(dst, "{value}").unwrap(); Ok(()) } diff --git a/crates/toml/src/value.rs b/crates/toml/src/value.rs index c689b383..1052fced 100644 --- a/crates/toml/src/value.rs +++ b/crates/toml/src/value.rs @@ -530,7 +530,7 @@ impl<'de> de::Deserialize<'de> for Value { if let crate::map::Entry::Vacant(vacant) = map.entry(&key) { vacant.insert(visitor.next_value()?); } else { - let msg = format!("duplicate key: `{}`", key); + let msg = format!("duplicate key: `{key}`"); return Err(de::Error::custom(msg)); } } @@ -808,7 +808,7 @@ impl<'de> de::VariantAccess<'de> for MapEnumDeserializer { if values.len() == len { de::Deserializer::deserialize_seq(values.into_deserializer(), visitor) } else { - Err(Error::custom(format!("expected tuple with length {}", len))) + Err(Error::custom(format!("expected tuple with length {len}"))) } } Value::Table(values) => { @@ -818,8 +818,7 @@ impl<'de> de::VariantAccess<'de> for MapEnumDeserializer { .map(|(index, (key, value))| match key.parse::() { Ok(key_index) if key_index == index => Ok(value), Ok(_) | Err(_) => Err(Error::custom(format!( - "expected table key `{}`, but was `{}`", - index, key + "expected table key `{index}`, but was `{key}`" ))), }) .collect(); @@ -828,7 +827,7 @@ impl<'de> de::VariantAccess<'de> for MapEnumDeserializer { if tuple_values.len() == len { de::Deserializer::deserialize_seq(tuple_values.into_deserializer(), visitor) } else { - Err(Error::custom(format!("expected tuple with length {}", len))) + Err(Error::custom(format!("expected tuple with length {len}"))) } } e => Err(Error::custom(format!( diff --git a/crates/toml/tests/testsuite/spanned.rs b/crates/toml/tests/testsuite/spanned.rs index daf7601b..b5c17d46 100644 --- a/crates/toml/tests/testsuite/spanned.rs +++ b/crates/toml/tests/testsuite/spanned.rs @@ -82,7 +82,7 @@ fn test_spanned_field() { ); for expected in good_datetimes() { - let s = format!("foo = {}", expected); + let s = format!("foo = {expected}"); good::(&s, expected, None); } // ending at something other than the absolute end diff --git a/crates/toml_datetime/src/datetime.rs b/crates/toml_datetime/src/datetime.rs index cea13b9f..d4a93615 100644 --- a/crates/toml_datetime/src/datetime.rs +++ b/crates/toml_datetime/src/datetime.rs @@ -238,16 +238,16 @@ impl From