From e47ca9c683c044a5c5350334188b051b8d15a956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Thu, 11 Sep 2025 15:05:02 -0700 Subject: [PATCH] fix(fmt+clippy): sigh --- clippy.toml | 2 +- examples/insert-node.rs | 2 +- src/document.rs | 12 ++++++------ src/entry.rs | 4 ++-- src/identifier.rs | 6 +++--- src/v2_parser.rs | 5 ++++- src/value.rs | 20 +++++++------------- 7 files changed, 24 insertions(+), 27 deletions(-) diff --git a/clippy.toml b/clippy.toml index f634529..8c0bc00 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.71.1" +msrv = "1.81" diff --git a/examples/insert-node.rs b/examples/insert-node.rs index 223ccfa..2b22962 100644 --- a/examples/insert-node.rs +++ b/examples/insert-node.rs @@ -29,7 +29,7 @@ words { word_nodes.sort_by(sort_by_name); words_section.autoformat(); - println!("{}", doc); + println!("{doc}"); // output: // words { diff --git a/src/document.rs b/src/document.rs index bc20992..6d313a1 100644 --- a/src/document.rs +++ b/src/document.rs @@ -696,21 +696,21 @@ final;"; let bar = doc.get("bar").expect("expected a bar node"); assert_eq!( - format!("{}", bar), + format!("{bar}"), "\n bar \"indented\" // trailing whitespace after this\t\n" ); let a = doc.get("a").expect("expected a node"); assert_eq!( - format!("{}", a), + format!("{a}"), "/*\nSome random comment\n */\n\na;".to_string() ); let b = doc.get("b").expect("expected a node"); - assert_eq!(format!("{}", b), " b;".to_string()); + assert_eq!(format!("{b}"), " b;".to_string()); // Round-tripping works. - assert_eq!(format!("{}", doc), src); + assert_eq!(format!("{doc}"), src); // Programmatic manipulation works. let mut node: KdlNode = "new\n".parse()?; @@ -721,7 +721,7 @@ final;"; doc.nodes_mut().push(node); assert_eq!( - format!("{}", doc), + format!("{doc}"), format!("{}new \"blah\"=0xDEADbeef\n", src) ); @@ -754,7 +754,7 @@ bar prop=value 1 2 #false #null { } baz "#, - format!("{}", doc) + format!("{doc}") ); } diff --git a/src/entry.rs b/src/entry.rs index 8d8b555..94f87b8 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -633,10 +633,10 @@ mod test { #[test] fn display() { let entry = KdlEntry::new(KdlValue::Integer(42)); - assert_eq!(format!("{}", entry), "42"); + assert_eq!(format!("{entry}"), "42"); let entry = KdlEntry::new_prop("name", KdlValue::Integer(42)); - assert_eq!(format!("{}", entry), "name=42"); + assert_eq!(format!("{entry}"), "name=42"); } #[cfg(feature = "v1")] diff --git a/src/identifier.rs b/src/identifier.rs index 5f86b50..1522cc8 100644 --- a/src/identifier.rs +++ b/src/identifier.rs @@ -215,13 +215,13 @@ mod test { #[test] fn formatting() { let plain = KdlIdentifier::from("foo"); - assert_eq!(format!("{}", plain), "foo"); + assert_eq!(format!("{plain}"), "foo"); let quoted = KdlIdentifier::from("foo\"bar"); - assert_eq!(format!("{}", quoted), r#""foo\"bar""#); + assert_eq!(format!("{quoted}"), r#""foo\"bar""#); let mut custom_repr = KdlIdentifier::from("foo"); custom_repr.set_repr(r#""foo/bar""#.to_string()); - assert_eq!(format!("{}", custom_repr), r#""foo/bar""#); + assert_eq!(format!("{custom_repr}"), r#""foo/bar""#); } } diff --git a/src/v2_parser.rs b/src/v2_parser.rs index 776c21a..8e3c7de 100644 --- a/src/v2_parser.rs +++ b/src/v2_parser.rs @@ -966,7 +966,10 @@ fn unambiguous_ident(input: &mut Input<'_>) -> PResult<()> { cut_err( repeat(1.., identifier_char) .verify_map(|s: String| { - if matches!(s.as_str(), "true" | "false" | "null" | "inf" | "-inf" | "nan") { + if matches!( + s.as_str(), + "true" | "false" | "null" | "inf" | "-inf" | "nan" + ) { None } else { Some(s) diff --git a/src/value.rs b/src/value.rs index 430d973..50853c0 100644 --- a/src/value.rs +++ b/src/value.rs @@ -38,9 +38,7 @@ impl PartialEq for KdlValue { match (self, other) { (Self::String(l0), Self::String(r0)) => l0 == r0, (Self::Integer(l0), Self::Integer(r0)) => l0 == r0, - (Self::Float(l0), Self::Float(r0)) => { - normalize_float(l0) == normalize_float(r0) - } + (Self::Float(l0), Self::Float(r0)) => normalize_float(l0) == normalize_float(r0), (Self::Bool(l0), Self::Bool(r0)) => l0 == r0, _ => core::mem::discriminant(self) == core::mem::discriminant(other), } @@ -161,11 +159,7 @@ pub(crate) fn is_plain_ident(ident: &str) -> bool { .find(crate::v2_parser::is_disallowed_ident_char) .is_none() && ident_bytes.first().map(|c| c.is_ascii_digit()) != Some(true) - && !(ident - .chars() - .next() - .map(|c| matches!(c, '.' | '-' | '+')) - == Some(true) + && !(ident.chars().next().map(|c| matches!(c, '.' | '-' | '+')) == Some(true) && ident_bytes.get(1).map(|c| c.is_ascii_digit()) == Some(true)) && ident != "inf" && ident != "-inf" @@ -272,18 +266,18 @@ mod test { #[test] fn formatting() { let string = KdlValue::String("foo\n".into()); - assert_eq!(format!("{}", string), r#""foo\n""#); + assert_eq!(format!("{string}"), r#""foo\n""#); let integer = KdlValue::Integer(1234567890); - assert_eq!(format!("{}", integer), "1234567890"); + assert_eq!(format!("{integer}"), "1234567890"); let float = KdlValue::Float(1234567890.12345); - assert_eq!(format!("{}", float), "1234567890.12345"); + assert_eq!(format!("{float}"), "1234567890.12345"); let boolean = KdlValue::Bool(true); - assert_eq!(format!("{}", boolean), "#true"); + assert_eq!(format!("{boolean}"), "#true"); let null = KdlValue::Null; - assert_eq!(format!("{}", null), "#null"); + assert_eq!(format!("{null}"), "#null"); } }