From 3688064ff5cf72a3568bca496c4241ae373948be Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 7 Feb 2024 16:53:27 +0100 Subject: [PATCH] Clippy --- crates/salsa/Cargo.toml | 3 +++ crates/salsa/salsa-macros/Cargo.toml | 3 +++ crates/salsa/salsa-macros/src/database_storage.rs | 12 +++--------- crates/salsa/salsa-macros/src/lib.rs | 2 -- crates/salsa/salsa-macros/src/parenthesized.rs | 2 +- crates/salsa/salsa-macros/src/query_group.rs | 7 ------- crates/salsa/tests/cycles.rs | 12 +----------- crates/salsa/tests/incremental/implementation.rs | 1 + crates/salsa/tests/no_send_sync.rs | 2 -- crates/salsa/tests/on_demand_inputs.rs | 6 ++---- crates/salsa/tests/parallel/setup.rs | 11 +++-------- 11 files changed, 17 insertions(+), 44 deletions(-) diff --git a/crates/salsa/Cargo.toml b/crates/salsa/Cargo.toml index 5cd351c0cab..4ccbc3de846 100644 --- a/crates/salsa/Cargo.toml +++ b/crates/salsa/Cargo.toml @@ -30,3 +30,6 @@ rand = "0.8.5" test-log = "0.2.14" expect-test = "1.4.0" dissimilar = "1.0.7" + +[lints] +workspace = true diff --git a/crates/salsa/salsa-macros/Cargo.toml b/crates/salsa/salsa-macros/Cargo.toml index 8d60a3244d6..791d2f6e9f5 100644 --- a/crates/salsa/salsa-macros/Cargo.toml +++ b/crates/salsa/salsa-macros/Cargo.toml @@ -18,3 +18,6 @@ heck = "0.4" proc-macro2 = "1.0" quote = "1.0" syn = { version = "2.0", features = ["full", "extra-traits"] } + +[lints] +workspace = true diff --git a/crates/salsa/salsa-macros/src/database_storage.rs b/crates/salsa/salsa-macros/src/database_storage.rs index 26b8e613099..0ec75bb043d 100644 --- a/crates/salsa/salsa-macros/src/database_storage.rs +++ b/crates/salsa/salsa-macros/src/database_storage.rs @@ -203,12 +203,6 @@ pub(crate) fn database(args: TokenStream, input: TokenStream) -> TokenStream { output.extend(has_group_impls); - if std::env::var("SALSA_DUMP").is_ok() { - println!("~~~ database_storage"); - println!("{}", output); - println!("~~~ database_storage"); - } - output.into() } @@ -218,7 +212,7 @@ struct QueryGroupList { } impl Parse for QueryGroupList { - fn parse(input: ParseStream) -> syn::Result { + fn parse(input: ParseStream<'_>) -> syn::Result { let query_groups: PunctuatedQueryGroups = input.parse_terminated(QueryGroup::parse, Token![,])?; Ok(QueryGroupList { query_groups }) @@ -241,7 +235,7 @@ impl Parse for QueryGroup { /// ```ignore /// impl HelloWorldDatabase; /// ``` - fn parse(input: ParseStream) -> syn::Result { + fn parse(input: ParseStream<'_>) -> syn::Result { let group_path: Path = input.parse()?; Ok(QueryGroup { group_path }) } @@ -250,7 +244,7 @@ impl Parse for QueryGroup { struct Nothing; impl Parse for Nothing { - fn parse(_input: ParseStream) -> syn::Result { + fn parse(_input: ParseStream<'_>) -> syn::Result { Ok(Nothing) } } diff --git a/crates/salsa/salsa-macros/src/lib.rs b/crates/salsa/salsa-macros/src/lib.rs index e50236fe7b3..8af48b1e3f8 100644 --- a/crates/salsa/salsa-macros/src/lib.rs +++ b/crates/salsa/salsa-macros/src/lib.rs @@ -2,8 +2,6 @@ #![recursion_limit = "256"] -extern crate proc_macro; -extern crate proc_macro2; #[macro_use] extern crate quote; diff --git a/crates/salsa/salsa-macros/src/parenthesized.rs b/crates/salsa/salsa-macros/src/parenthesized.rs index d61166cecd7..9df41e03c16 100644 --- a/crates/salsa/salsa-macros/src/parenthesized.rs +++ b/crates/salsa/salsa-macros/src/parenthesized.rs @@ -5,7 +5,7 @@ impl syn::parse::Parse for Parenthesized where T: syn::parse::Parse, { - fn parse(input: syn::parse::ParseStream) -> syn::Result { + fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result { let content; syn::parenthesized!(content in input); content.parse::().map(Parenthesized) diff --git a/crates/salsa/salsa-macros/src/query_group.rs b/crates/salsa/salsa-macros/src/query_group.rs index 0b1ee2d3b57..7d0eac9f5d8 100644 --- a/crates/salsa/salsa-macros/src/query_group.rs +++ b/crates/salsa/salsa-macros/src/query_group.rs @@ -625,13 +625,6 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream } // ANCHOR_END:group_storage_methods }); - - if std::env::var("SALSA_DUMP").is_ok() { - println!("~~~ query_group"); - println!("{}", output); - println!("~~~ query_group"); - } - output.into() } diff --git a/crates/salsa/tests/cycles.rs b/crates/salsa/tests/cycles.rs index 0f89c6375fb..00ca5332440 100644 --- a/crates/salsa/tests/cycles.rs +++ b/crates/salsa/tests/cycles.rs @@ -51,6 +51,7 @@ struct Error { } #[salsa::database(GroupStruct)] +#[derive(Default)] struct DatabaseImpl { storage: salsa::Storage, } @@ -63,14 +64,6 @@ impl ParallelDatabase for DatabaseImpl { } } -impl Default for DatabaseImpl { - fn default() -> Self { - let res = DatabaseImpl { storage: salsa::Storage::default() }; - - res - } -} - /// The queries A, B, and C in `Database` can be configured /// to invoke one another in arbitrary ways using this /// enum. @@ -151,17 +144,14 @@ impl CycleQuery { } fn cycle_a(db: &dyn Database) -> Result<(), Error> { - dbg!("cycle_a"); db.a_invokes().invoke(db) } fn cycle_b(db: &dyn Database) -> Result<(), Error> { - dbg!("cycle_b"); db.b_invokes().invoke(db) } fn cycle_c(db: &dyn Database) -> Result<(), Error> { - dbg!("cycle_c"); db.c_invokes().invoke(db) } diff --git a/crates/salsa/tests/incremental/implementation.rs b/crates/salsa/tests/incremental/implementation.rs index 445154e85a0..19752bba005 100644 --- a/crates/salsa/tests/incremental/implementation.rs +++ b/crates/salsa/tests/incremental/implementation.rs @@ -33,6 +33,7 @@ impl TestContextImpl { return; } + #[allow(clippy::print_stdout)] for diff in dissimilar::diff(expected_text, actual_text) { match diff { dissimilar::Chunk::Delete(l) => println!("-{}", l), diff --git a/crates/salsa/tests/no_send_sync.rs b/crates/salsa/tests/no_send_sync.rs index 2648f2b7a45..2a25c437c3e 100644 --- a/crates/salsa/tests/no_send_sync.rs +++ b/crates/salsa/tests/no_send_sync.rs @@ -1,5 +1,3 @@ -extern crate salsa; - use std::rc::Rc; #[salsa::query_group(NoSendSyncStorage)] diff --git a/crates/salsa/tests/on_demand_inputs.rs b/crates/salsa/tests/on_demand_inputs.rs index 61039ae7b2b..5d0e4866442 100644 --- a/crates/salsa/tests/on_demand_inputs.rs +++ b/crates/salsa/tests/on_demand_inputs.rs @@ -4,6 +4,8 @@ //! via a b query with zero inputs, which uses `add_synthetic_read` to //! tweak durability and `invalidate` to clear the input. +#![allow(clippy::disallowed_types, clippy::type_complexity)] + use std::{cell::RefCell, collections::HashMap, rc::Rc}; use salsa::{Database as _, Durability, EventKind}; @@ -40,8 +42,6 @@ struct Database { impl salsa::Database for Database { fn salsa_event(&self, event: salsa::Event) { - dbg!(event.debug(self)); - if let Some(cb) = &self.on_event { cb(self, event) } @@ -111,7 +111,6 @@ fn on_demand_input_durability() { } "#]].assert_debug_eq(&events); - eprintln!("------------------"); db.salsa_runtime_mut().synthetic_write(Durability::LOW); events.replace(vec![]); assert_eq!(db.c(1), 10); @@ -129,7 +128,6 @@ fn on_demand_input_durability() { } "#]].assert_debug_eq(&events); - eprintln!("------------------"); db.salsa_runtime_mut().synthetic_write(Durability::HIGH); events.replace(vec![]); assert_eq!(db.c(1), 10); diff --git a/crates/salsa/tests/parallel/setup.rs b/crates/salsa/tests/parallel/setup.rs index 0f7d06542f1..0a35902b435 100644 --- a/crates/salsa/tests/parallel/setup.rs +++ b/crates/salsa/tests/parallel/setup.rs @@ -46,7 +46,7 @@ impl WithValue for Cell { fn with_value(&self, value: T, closure: impl FnOnce() -> R) -> R { let old_value = self.replace(value); - let result = catch_unwind(AssertUnwindSafe(|| closure())); + let result = catch_unwind(AssertUnwindSafe(closure)); self.set(old_value); @@ -57,18 +57,13 @@ impl WithValue for Cell { } } -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Default, Clone, Copy, PartialEq, Eq)] pub(crate) enum CancellationFlag { + #[default] Down, Panic, } -impl Default for CancellationFlag { - fn default() -> CancellationFlag { - CancellationFlag::Down - } -} - /// Various "knobs" that can be used to customize how the queries /// behave on one specific thread. Note that this state is /// intentionally thread-local (apart from `signal`).