From 806fabc4c7aa1ff2982fdf949324050a6f46bd11 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Sat, 27 Apr 2024 20:23:59 -0700 Subject: [PATCH] run clippy for no, default, and all features This should be good enough for now. --- engage.toml | 28 +++++++++++++++++++++++++++- src/database/mod.rs | 24 ++++++++++++------------ src/utils/mod.rs | 1 + 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/engage.toml b/engage.toml index 3e8884eb..ec3b4066 100644 --- a/engage.toml +++ b/engage.toml @@ -47,10 +47,36 @@ RUSTDOCFLAGS="-D warnings" cargo doc \ """ [[task]] -name = "cargo-clippy" +name = "cargo-clippy/none" +group = "lints" +script = """ +cargo clippy \ + --workspace \ + --all-targets \ + --no-default-features \ + --color=always \ + -- \ + -D warnings +""" + +[[task]] +name = "cargo-clippy/default" group = "lints" script = "cargo clippy --workspace --all-targets --color=always -- -D warnings" +[[task]] +name = "cargo-clippy/all" +group = "lints" +script = """ +cargo clippy \ + --workspace \ + --all-targets \ + --all-features \ + --color=always \ + -- \ + -D warnings +""" + [[task]] name = "cargo" group = "tests" diff --git a/src/database/mod.rs b/src/database/mod.rs index dadf9cbc..6941b22b 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -210,6 +210,10 @@ impl KeyValueDatabase { } /// Load an existing database or create a new one. + #[cfg_attr( + not(any(feature = "rocksdb", feature = "sqlite")), + allow(unreachable_code) + )] pub async fn load_or_create(config: Config) -> Result<()> { Self::check_db_setup(&config)?; @@ -218,19 +222,15 @@ impl KeyValueDatabase { .map_err(|_| Error::BadConfig("Database folder doesn't exists and couldn't be created (e.g. due to missing permissions). Please create the database folder yourself."))?; } + #[cfg_attr( + not(any(feature = "rocksdb", feature = "sqlite")), + allow(unused_variables) + )] let builder: Arc = match &*config.database_backend { - "sqlite" => { - #[cfg(not(feature = "sqlite"))] - return Err(Error::BadConfig("Database backend not found.")); - #[cfg(feature = "sqlite")] - Arc::new(Arc::::open(&config)?) - } - "rocksdb" => { - #[cfg(not(feature = "rocksdb"))] - return Err(Error::BadConfig("Database backend not found.")); - #[cfg(feature = "rocksdb")] - Arc::new(Arc::::open(&config)?) - } + #[cfg(feature = "sqlite")] + "sqlite" => Arc::new(Arc::::open(&config)?), + #[cfg(feature = "rocksdb")] + "rocksdb" => Arc::new(Arc::::open(&config)?), _ => { return Err(Error::BadConfig("Database backend not found.")); } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 0b5b1ae4..0ac81b62 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -18,6 +18,7 @@ pub fn millis_since_unix_epoch() -> u64 { .as_millis() as u64 } +#[cfg(any(feature = "rocksdb", feature = "sqlite"))] pub fn increment(old: Option<&[u8]>) -> Option> { let number = match old.map(|bytes| bytes.try_into()) { Some(Ok(bytes)) => {