From 6a7de26e5ab13fe902ef4fd0eade0db6e3f173a1 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 21 Oct 2024 19:29:33 -0700 Subject: [PATCH] Ignore uninlined_format_args pedantic clippy lint warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/attr.rs:546:36 | 546 | meta.error(format_args!("unknown serde container attribute `{}`", path)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args = note: `-W clippy::uninlined-format-args` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::uninlined_format_args)]` help: change this to | 546 - meta.error(format_args!("unknown serde container attribute `{}`", path)) 546 + meta.error(format_args!("unknown serde container attribute `{path}`")) | warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/attr.rs:940:36 | 940 | meta.error(format_args!("unknown serde variant attribute `{}`", path)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 940 - meta.error(format_args!("unknown serde variant attribute `{}`", path)) 940 + meta.error(format_args!("unknown serde variant attribute `{path}`")) | warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/attr.rs:1095:33 | 1095 | ... format!("field `{}` does not have lifetime {}", ident, lifetime); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1095 - format!("field `{}` does not have lifetime {}", ident, lifetime); 1095 + format!("field `{ident}` does not have lifetime {lifetime}"); | warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/attr.rs:1196:47 | 1196 | ... let msg = format!( | _________________________________^ 1197 | | ... "field `{}` does not have lifetime {}", 1198 | | ... ident, lifetime, 1199 | | ... ); | |_______________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/attr.rs:1222:36 | 1222 | meta.error(format_args!("unknown serde field attribute `{}`", path)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1222 - meta.error(format_args!("unknown serde field attribute `{}`", path)) 1222 + meta.error(format_args!("unknown serde field attribute `{path}`")) | warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/attr.rs:1415:39 | 1415 | return Err(meta.error(format_args!( | _______________________________________^ 1416 | | "malformed {0} attribute, expected `{0}(serialize = ..., deserialize = ...)`", 1417 | | attr_name, 1418 | | ))); | |_________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/attr.rs:1482:17 | 1482 | format!("unexpected suffix `{}` on string literal", suffix), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1482 - format!("unexpected suffix `{}` on string literal", suffix), 1482 + format!("unexpected suffix `{suffix}` on string literal"), | warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/attr.rs:1489:13 | 1489 | / format!( 1490 | | "expected serde {} attribute to be a string: `{} = \"...\"`", 1491 | | attr_name, meta_item_name 1492 | | ), | |_____________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/attr.rs:1604:21 | 1604 | format!("duplicate borrowed lifetime `{}`", lifetime), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1604 - format!("duplicate borrowed lifetime `{}`", lifetime), 1604 + format!("duplicate borrowed lifetime `{lifetime}`"), | warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/attr.rs:1778:19 | 1778 | let msg = format!("field `{}` has no lifetimes to borrow", name); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1778 - let msg = format!("field `{}` has no lifetimes to borrow", name); 1778 + let msg = format!("field `{name}` has no lifetimes to borrow"); | warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/check.rs:41:29 | 41 | ... format!("field must have #[serde(default)] because previous field {} has #[serde(default)]", first), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 41 - format!("field must have #[serde(default)] because previous field {} has #[serde(default)]", first), 41 + format!("field must have #[serde(default)] because previous field {first} has #[serde(default)]"), | warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/check.rs:314:13 | 314 | format!("variant field name `{}` conflicts with internal tag", tag), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 314 - format!("variant field name `{}` conflicts with internal tag", tag), 314 + format!("variant field name `{tag}` conflicts with internal tag"), | warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/check.rs:361:13 | 361 | / format!( 362 | | "enum tags `{}` for type and content conflict with each other", 363 | | type_tag 364 | | ), | |_____________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args warning: variables can be used directly in the `format!` string --> serde_derive/src/internals/check.rs:450:33 | 450 | Member::Named(ident) => format!("`{}`", ident), | ^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 450 - Member::Named(ident) => format!("`{}`", ident), 450 + Member::Named(ident) => format!("`{ident}`"), | warning: variables can be used directly in the `format!` string --> serde_derive/src/de.rs:697:9 | 697 | format!("{} with 1 element", expecting) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 697 - format!("{} with 1 element", expecting) 697 + format!("{expecting} with 1 element") | warning: variables can be used directly in the `format!` string --> serde_derive/src/de.rs:699:9 | 699 | format!("{} with {} elements", expecting, deserialized_count) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 699 - format!("{} with {} elements", expecting, deserialized_count) 699 + format!("{expecting} with {deserialized_count} elements") | warning: variables can be used directly in the `format!` string --> serde_derive/src/de.rs:1442:21 | 1442 | let expecting = format!("adjacently tagged enum {}", rust_name); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1442 - let expecting = format!("adjacently tagged enum {}", rust_name); 1442 + let expecting = format!("adjacently tagged enum {rust_name}"); | warning: variables can be used directly in the `format!` string --> serde_derive/src/de.rs:2842:17 | 2842 | Ident::new(&format!("__field{}", i), Span::call_site()) | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 2842 - Ident::new(&format!("__field{}", i), Span::call_site()) 2842 + Ident::new(&format!("__field{i}"), Span::call_site()) | warning: variables can be used directly in the `format!` string --> serde_derive/src/ser.rs:457:42 | 457 | .map(|i| Ident::new(&format!("__field{}", i), Span::call_site())); | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 457 - .map(|i| Ident::new(&format!("__field{}", i), Span::call_site())); 457 + .map(|i| Ident::new(&format!("__field{i}"), Span::call_site())); | warning: variables can be used directly in the `format!` string --> serde_derive/src/ser.rs:714:48 | 714 | .map(|i| Member::Named(Ident::new(&format!("__field{}", i), Span::call_site()))) | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 714 - .map(|i| Member::Named(Ident::new(&format!("__field{}", i), Span::call_site()))) 714 + .map(|i| Member::Named(Ident::new(&format!("__field{i}"), Span::call_site()))) | warning: variables can be used directly in the `format!` string --> serde_derive/src/ser.rs:832:46 | 832 | let field_expr = Ident::new(&format!("__field{}", i), Span::call_site()); | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 832 - let field_expr = Ident::new(&format!("__field{}", i), Span::call_site()); 832 + let field_expr = Ident::new(&format!("__field{i}"), Span::call_site()); | warning: variables can be used directly in the `format!` string --> serde_derive/src/ser.rs:1062:38 | 1062 | let id = Ident::new(&format!("__field{}", i), Span::call_site()); | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1062 - let id = Ident::new(&format!("__field{}", i), Span::call_site()); 1062 + let id = Ident::new(&format!("__field{i}"), Span::call_site()); | --- serde_derive/src/lib.rs | 1 + serde_derive_internals/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/serde_derive/src/lib.rs b/serde_derive/src/lib.rs index 1e415fb20..15a10cd2f 100644 --- a/serde_derive/src/lib.rs +++ b/serde_derive/src/lib.rs @@ -56,6 +56,7 @@ clippy::single_match_else, clippy::struct_excessive_bools, clippy::too_many_lines, + clippy::uninlined_format_args, clippy::unseparated_literal_suffix, clippy::unused_self, clippy::use_self, diff --git a/serde_derive_internals/lib.rs b/serde_derive_internals/lib.rs index c907b5a24..d07485771 100644 --- a/serde_derive_internals/lib.rs +++ b/serde_derive_internals/lib.rs @@ -36,6 +36,7 @@ clippy::single_match_else, clippy::struct_excessive_bools, clippy::too_many_lines, + clippy::uninlined_format_args, clippy::unused_self, clippy::wildcard_imports )]