From bbca41c5eebbc28dd508a320753c52753abf6cf8 Mon Sep 17 00:00:00 2001 From: oxalica Date: Fri, 10 Mar 2023 15:59:30 +0800 Subject: [PATCH] Apply `clippy::uninlined_format_args` --- crates/ide/src/def/tests.rs | 2 +- crates/ide/src/ide/rename.rs | 6 +++--- crates/ide/src/tests.rs | 2 +- crates/nil/src/main.rs | 3 +-- crates/syntax/src/lib.rs | 2 +- crates/syntax/src/tests.rs | 2 +- flake.nix | 4 +++- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/ide/src/def/tests.rs b/crates/ide/src/def/tests.rs index fcbe582..4a913c5 100644 --- a/crates/ide/src/def/tests.rs +++ b/crates/ide/src/def/tests.rs @@ -61,7 +61,7 @@ baz/../../bar.nix + ../default.nix for (src, refs) in asserts { let got = &*db.module_references(f[src]); let expect = refs.iter().map(|path| f[*path]).collect::>(); - assert_eq!(got, &expect, "Module {:?} should reference {:?}", src, refs); + assert_eq!(got, &expect, "Module {src:?} should reference {refs:?}"); } } diff --git a/crates/ide/src/ide/rename.rs b/crates/ide/src/ide/rename.rs index d486c09..b0d6270 100644 --- a/crates/ide/src/ide/rename.rs +++ b/crates/ide/src/ide/rename.rs @@ -78,7 +78,7 @@ pub(crate) fn rename( // `new = old;`. edits.push(TextEdit { delete: TextRange::empty(i.syntax().text_range().end()), - insert: format!("{} = {};", new_attr, old_attr).into(), + insert: format!("{new_attr} = {old_attr};").into(), }); } Some(from_expr) => { @@ -142,7 +142,7 @@ pub(crate) fn rename( // Then construct a new binding. edits.push(TextEdit { delete: TextRange::empty(i.syntax().text_range().end()), - insert: format!("{} = {};", old_attr, new_attr).into(), + insert: format!("{old_attr} = {new_attr};").into(), }); } @@ -227,7 +227,7 @@ mod tests { if is_same { src } else { - format!("{}\n{}\n", src, text) + format!("{src}\n{text}\n") } } Err(err) => err, diff --git a/crates/ide/src/tests.rs b/crates/ide/src/tests.rs index bc1450c..110c6b7 100644 --- a/crates/ide/src/tests.rs +++ b/crates/ide/src/tests.rs @@ -171,7 +171,7 @@ impl Fixture { .into_iter() .take(marker_len) .enumerate() - .map(|(i, p)| p.with_context(|| format!("Discontinuous marker: {}", i))) + .map(|(i, p)| p.with_context(|| format!("Discontinuous marker: {i}"))) .collect::>>()?; Ok(this) diff --git a/crates/nil/src/main.rs b/crates/nil/src/main.rs index b551335..8f45871 100644 --- a/crates/nil/src/main.rs +++ b/crates/nil/src/main.rs @@ -67,8 +67,7 @@ fn main() { match nil::main_loop(conn).and_then(|()| io_threads.join().map_err(Into::into)) { Ok(()) => {} Err(err) => { - tracing::error!("Unexpected error: {}", err); - eprintln!("{}", err); + tracing::error!("Unexpected error: {err:#}"); process::exit(101); } } diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index 3bb02e5..6c42163 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs @@ -51,7 +51,7 @@ impl fmt::Display for ErrorKind { Self::NestTooDeep => "Nest too deep", Self::MultipleRoots => "Multiple top-level expressions are not allowed", Self::MultipleNoAssoc => "No-associative operators cannot be chained", - Self::ExpectToken(tok) => return write!(f, "Expecting {}", tok), + Self::ExpectToken(tok) => return write!(f, "Expecting {tok}"), Self::ExpectExpr => "Expecting an expression", Self::ExpectElemExpr => "Expecting a list element expression. Forget parentheses?", Self::ExpectAttr => { diff --git a/crates/syntax/src/tests.rs b/crates/syntax/src/tests.rs index 10d7dae..b1f54c7 100644 --- a/crates/syntax/src/tests.rs +++ b/crates/syntax/src/tests.rs @@ -41,7 +41,7 @@ fn run_test(dir: &Path, ok: bool) { write!(got, "{:#?}", ast.syntax_node()).unwrap(); if ok != ast.errors().is_empty() { - println!("--------\n{}\n--------", got); + println!("--------\n{got}\n--------"); panic!("Unexpected test result for {}", path.display()); } diff --git a/flake.nix b/flake.nix index c40ce4a..1de021d 100644 --- a/flake.nix +++ b/flake.nix @@ -53,11 +53,13 @@ "-D" "warnings" "-D" "clippy::dbg_macro" + "-D" "clippy::todo" + "-D" "clippy::doc_markdown" "-D" "clippy::manual-let-else" "-D" "clippy::missing-panics-doc" "-D" "clippy::semicolon_if_nothing_returned" - "-D" "clippy::todo" + "-D" "clippy::uninlined_format_args" ]; pre-commit = pkgs.writeShellScriptBin "pre-commit" ''