From 516fdff567f903c9a5e5d3a3682dfbc0c0a36a30 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 7 Oct 2022 22:16:16 -0700 Subject: [PATCH] Ignore uninlined_format_args pedantic clippy lint error: variables can be used directly in the `format!` string --> src/de.rs:999:24 | 999 | let negative = format!("-{}", rest); | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args = note: `-D clippy::uninlined-format-args` implied by `-D clippy::pedantic` help: change this to | 999 - let negative = format!("-{}", rest); 999 + let negative = format!("-{rest}"); | error: variables can be used directly in the `format!` string --> src/de.rs:1013:24 | 1013 | let negative = format!("-{}", rest); | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1013 - let negative = format!("-{}", rest); 1013 + let negative = format!("-{rest}"); | error: variables can be used directly in the `format!` string --> src/de.rs:1027:24 | 1027 | let negative = format!("-{}", rest); | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1027 - let negative = format!("-{}", rest); 1027 + let negative = format!("-{rest}"); | error: variables can be used directly in the `format!` string --> src/de.rs:1043:24 | 1043 | let negative = format!("-{}", rest); | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1043 - let negative = format!("-{}", rest); 1043 + let negative = format!("-{rest}"); | error: variables can be used directly in the `format!` string --> src/de.rs:1049:24 | 1049 | let negative = format!("-{}", rest); | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1049 - let negative = format!("-{}", rest); 1049 + let negative = format!("-{rest}"); | error: variables can be used directly in the `format!` string --> src/de.rs:1055:24 | 1055 | let negative = format!("-{}", rest); | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 1055 - let negative = format!("-{}", rest); 1055 + let negative = format!("-{rest}"); | error: variables can be used directly in the `format!` string --> src/error.rs:210:21 | 210 | write!(f, "{}: ", path)?; | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 210 - write!(f, "{}: ", path)?; 210 + write!(f, "{path}: ")?; | error: variables can be used directly in the `format!` string --> src/error.rs:252:25 | 252 | write!(f, " at {}", mark)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 252 - write!(f, " at {}", mark)?; 252 + write!(f, " at {mark}")?; | error: variables can be used directly in the `format!` string --> src/libyaml/cstr.rs:119:21 | 119 | write!(formatter, "\\x{:02x}", b)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 119 - write!(formatter, "\\x{:02x}", b)?; 119 + write!(formatter, "\\x{b:02x}")?; | error: variables can be used directly in the `format!` string --> src/libyaml/error.rs:74:13 | 74 | write!(formatter, ", {}", context)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 74 - write!(formatter, ", {}", context)?; 74 + write!(formatter, ", {context}")?; | error: variables can be used directly in the `format!` string --> src/libyaml/error.rs:99:38 | 99 | formatter.field("kind", &format_args!("{}", kind)); | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 99 - formatter.field("kind", &format_args!("{}", kind)); 99 + formatter.field("kind", &format_args!("{kind}")); | error: variables can be used directly in the `format!` string --> src/mapping.rs:764:37 | 764 | Value::Bool(boolean) => write!(formatter, "with key `{}`", boolean), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 764 - Value::Bool(boolean) => write!(formatter, "with key `{}`", boolean), 764 + Value::Bool(boolean) => write!(formatter, "with key `{boolean}`"), | error: variables can be used directly in the `format!` string --> src/mapping.rs:765:38 | 765 | Value::Number(number) => write!(formatter, "with key {}", number), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 765 - Value::Number(number) => write!(formatter, "with key {}", number), 765 + Value::Number(number) => write!(formatter, "with key {number}"), | error: variables can be used directly in the `format!` string --> src/mapping.rs:766:38 | 766 | Value::String(string) => write!(formatter, "with key {:?}", string), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 766 - Value::String(string) => write!(formatter, "with key {:?}", string), 766 + Value::String(string) => write!(formatter, "with key {string:?}"), | error: variables can be used directly in the `format!` string --> src/path.rs:21:29 | 21 | path => write!(formatter, "{}.", path), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 21 - path => write!(formatter, "{}.", path), 21 + path => write!(formatter, "{path}."), | error: variables can be used directly in the `format!` string --> src/path.rs:28:44 | 28 | Path::Seq { parent, index } => write!(formatter, "{}[{}]", parent, index), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 28 - Path::Seq { parent, index } => write!(formatter, "{}[{}]", parent, index), 28 + Path::Seq { parent, index } => write!(formatter, "{parent}[{index}]"), | error: variables can be used directly in the `format!` string --> src/path.rs:29:42 | 29 | Path::Map { parent, key } => write!(formatter, "{}{}", Parent(parent), key), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 29 - Path::Map { parent, key } => write!(formatter, "{}{}", Parent(parent), key), 29 + Path::Map { parent, key } => write!(formatter, "{}{key}", Parent(parent)), | error: variables can be used directly in the `format!` string --> src/path.rs:30:39 | 30 | Path::Alias { parent } => write!(formatter, "{}", parent), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 30 - Path::Alias { parent } => write!(formatter, "{}", parent), 30 + Path::Alias { parent } => write!(formatter, "{parent}"), | error: variables can be used directly in the `format!` string --> src/value/debug.rs:9:37 | 9 | Value::Bool(boolean) => write!(formatter, "Bool({})", boolean), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 9 - Value::Bool(boolean) => write!(formatter, "Bool({})", boolean), 9 + Value::Bool(boolean) => write!(formatter, "Bool({boolean})"), | error: variables can be used directly in the `format!` string --> src/value/debug.rs:10:38 | 10 | Value::Number(number) => write!(formatter, "Number({})", number), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 10 - Value::Number(number) => write!(formatter, "Number({})", number), 10 + Value::Number(number) => write!(formatter, "Number({number})"), | error: variables can be used directly in the `format!` string --> src/value/debug.rs:11:38 | 11 | Value::String(string) => write!(formatter, "String({:?})", string), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 11 - Value::String(string) => write!(formatter, "String({:?})", string), 11 + Value::String(string) => write!(formatter, "String({string:?})"), | error: variables can be used directly in the `format!` string --> src/value/debug.rs:32:9 | 32 | write!(formatter, "Number({})", self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 32 - write!(formatter, "Number({})", self) 32 + write!(formatter, "Number({self})") | error: variables can be used directly in the `format!` string --> src/value/index.rs:60:22 | 60 | _ => panic!("cannot access index {} of YAML {}", self, Type(v)), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 60 - _ => panic!("cannot access index {} of YAML {}", self, Type(v)), 60 + _ => panic!("cannot access index {self} of YAML {}", Type(v)), | error: variables can be used directly in the `format!` string --> src/value/index.rs:107:18 | 107 | _ => panic!("cannot access key {:?} in YAML {}", index, Type(v)), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 107 - _ => panic!("cannot access key {:?} in YAML {}", index, Type(v)), 107 + _ => panic!("cannot access key {index:?} in YAML {}", Type(v)), | error: variables can be used directly in the `format!` string --> src/value/tagged.rs:372:36 | 372 | fmt::write(&mut check_for_tag, format_args!("{}", value)).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 372 - fmt::write(&mut check_for_tag, format_args!("{}", value)).unwrap(); 372 + fmt::write(&mut check_for_tag, format_args!("{value}")).unwrap(); | error: variables can be used directly in the `format!` string --> tests/test_value.rs:112:17 | 112 | let debug = format!("{:#?}", value); | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args = note: `-D clippy::uninlined-format-args` implied by `-D clippy::pedantic` help: change this to | 112 - let debug = format!("{:#?}", value); 112 + let debug = format!("{value:#?}"); | error: variables can be used directly in the `format!` string --> tests/test_de.rs:427:18 | 427 | _ => panic!("expected number. input={:?}, result={:?}", yaml, value), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args = note: `-D clippy::uninlined-format-args` implied by `-D clippy::pedantic` help: change this to | 427 - _ => panic!("expected number. input={:?}, result={:?}", yaml, value), 427 + _ => panic!("expected number. input={yaml:?}, result={value:?}"), | error: variables can be used directly in the `format!` string --> tests/test_de.rs:440:18 | 440 | _ => panic!("expected string. input={:?}, result={:?}", yaml, value), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args help: change this to | 440 - _ => panic!("expected string. input={:?}, result={:?}", yaml, value), 440 + _ => panic!("expected string. input={yaml:?}, result={value:?}"), | --- src/lib.rs | 1 + tests/test_de.rs | 3 ++- tests/test_value.rs | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9a18492b..d8467ab2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -153,6 +153,7 @@ clippy::never_loop, clippy::return_self_not_must_use, clippy::too_many_lines, + clippy::uninlined_format_args, clippy::unsafe_removed_from_name, clippy::wildcard_in_or_patterns, // noisy diff --git a/tests/test_de.rs b/tests/test_de.rs index f52e8f0c..49e2cc68 100644 --- a/tests/test_de.rs +++ b/tests/test_de.rs @@ -1,7 +1,8 @@ #![allow( clippy::cast_lossless, clippy::cast_possible_wrap, - clippy::derive_partial_eq_without_eq + clippy::derive_partial_eq_without_eq, + clippy::uninlined_format_args )] use indoc::indoc; diff --git a/tests/test_value.rs b/tests/test_value.rs index a2f4f291..a7dd448c 100644 --- a/tests/test_value.rs +++ b/tests/test_value.rs @@ -1,4 +1,8 @@ -#![allow(clippy::derive_partial_eq_without_eq, clippy::eq_op)] +#![allow( + clippy::derive_partial_eq_without_eq, + clippy::eq_op, + clippy::uninlined_format_args +)] use indoc::indoc; use serde::de::IntoDeserializer;