From 23c352b96bf07c981bb396fa34ce83e512ada0b2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 24 Jun 2022 13:24:00 +0100 Subject: [PATCH] clippy: Consolidate many lints in maint/add_warning Found these by disabling the nightly dbg macro special case. Now, we have a mechanism for globally adding suppressions to tests, we can use that instead. --- clippy-nightly.toml | 3 ++- crates/arti-client/examples/advanced_isolation.rs | 3 +++ crates/arti-client/examples/hook-tcp.rs | 3 +++ crates/arti-client/examples/lazy-init.rs | 3 +++ crates/arti-client/examples/readme.rs | 3 +++ crates/arti-hyper/examples/hyper.rs | 3 +++ crates/tor-basic-utils/src/futures.rs | 11 +++++++++-- crates/tor-chanmgr/src/mgr/map.rs | 3 +++ crates/tor-circmgr/src/path/dirpath.rs | 9 ++++++++- crates/tor-config/src/path.rs | 9 +++++++++ crates/tor-guardmgr/src/fallback/set.rs | 8 ++++++++ crates/tor-proto/src/channel/padding.rs | 12 +++++++++--- maint/add_warning | 3 +++ 13 files changed, 66 insertions(+), 7 deletions(-) diff --git a/clippy-nightly.toml b/clippy-nightly.toml index a0df6e2c4..af916ec64 100644 --- a/clippy-nightly.toml +++ b/clippy-nightly.toml @@ -3,4 +3,5 @@ # We must edit the tree, this way, sadly: # https://github.com/rust-lang/rust-clippy/issues/8973 -allow-dbg-in-tests = true +# (currently we do not need tohave anything here; everything is dealt with +# by suppressions maintained by maint/add_warning) diff --git a/crates/arti-client/examples/advanced_isolation.rs b/crates/arti-client/examples/advanced_isolation.rs index eaa9beb6c..adc6708d1 100644 --- a/crates/arti-client/examples/advanced_isolation.rs +++ b/crates/arti-client/examples/advanced_isolation.rs @@ -1,4 +1,7 @@ // @@ begin test lint list maintained by maint/add_warning @@ +#![allow(clippy::bool_assert_comparison)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::dbg_macro)] #![allow(clippy::print_stderr)] #![allow(clippy::print_stdout)] #![allow(clippy::unwrap_used)] diff --git a/crates/arti-client/examples/hook-tcp.rs b/crates/arti-client/examples/hook-tcp.rs index bd6f411bd..c3420c7e9 100644 --- a/crates/arti-client/examples/hook-tcp.rs +++ b/crates/arti-client/examples/hook-tcp.rs @@ -1,4 +1,7 @@ // @@ begin test lint list maintained by maint/add_warning @@ +#![allow(clippy::bool_assert_comparison)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::dbg_macro)] #![allow(clippy::print_stderr)] #![allow(clippy::print_stdout)] #![allow(clippy::unwrap_used)] diff --git a/crates/arti-client/examples/lazy-init.rs b/crates/arti-client/examples/lazy-init.rs index e5f9c340b..337e41b5e 100644 --- a/crates/arti-client/examples/lazy-init.rs +++ b/crates/arti-client/examples/lazy-init.rs @@ -1,4 +1,7 @@ // @@ begin test lint list maintained by maint/add_warning @@ +#![allow(clippy::bool_assert_comparison)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::dbg_macro)] #![allow(clippy::print_stderr)] #![allow(clippy::print_stdout)] #![allow(clippy::unwrap_used)] diff --git a/crates/arti-client/examples/readme.rs b/crates/arti-client/examples/readme.rs index 391ca5f65..8e48088ab 100644 --- a/crates/arti-client/examples/readme.rs +++ b/crates/arti-client/examples/readme.rs @@ -1,4 +1,7 @@ // @@ begin test lint list maintained by maint/add_warning @@ +#![allow(clippy::bool_assert_comparison)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::dbg_macro)] #![allow(clippy::print_stderr)] #![allow(clippy::print_stdout)] #![allow(clippy::unwrap_used)] diff --git a/crates/arti-hyper/examples/hyper.rs b/crates/arti-hyper/examples/hyper.rs index 80199aa1c..c8c27eb47 100644 --- a/crates/arti-hyper/examples/hyper.rs +++ b/crates/arti-hyper/examples/hyper.rs @@ -1,4 +1,7 @@ // @@ begin test lint list maintained by maint/add_warning @@ +#![allow(clippy::bool_assert_comparison)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::dbg_macro)] #![allow(clippy::print_stderr)] #![allow(clippy::print_stdout)] #![allow(clippy::unwrap_used)] diff --git a/crates/tor-basic-utils/src/futures.rs b/crates/tor-basic-utils/src/futures.rs index 5cce62724..ce7682dc9 100644 --- a/crates/tor-basic-utils/src/futures.rs +++ b/crates/tor-basic-utils/src/futures.rs @@ -413,9 +413,16 @@ where } #[cfg(test)] -#[allow(clippy::unwrap_used)] // why is this not the default in tests -#[allow(clippy::print_stderr)] mod test { + // @@ begin test lint list maintained by maint/add_warning @@ + #![allow(clippy::bool_assert_comparison)] + #![allow(clippy::clone_on_copy)] + #![allow(clippy::dbg_macro)] + #![allow(clippy::print_stderr)] + #![allow(clippy::print_stdout)] + #![allow(clippy::unwrap_used)] + //! + use super::*; use futures::channel::mpsc; use futures::future::poll_fn; diff --git a/crates/tor-chanmgr/src/mgr/map.rs b/crates/tor-chanmgr/src/mgr/map.rs index b62934414..c16739be8 100644 --- a/crates/tor-chanmgr/src/mgr/map.rs +++ b/crates/tor-chanmgr/src/mgr/map.rs @@ -366,6 +366,9 @@ fn update_padding_parameters_from_netdir( #[cfg(test)] mod test { // @@ begin test lint list maintained by maint/add_warning @@ + #![allow(clippy::bool_assert_comparison)] + #![allow(clippy::clone_on_copy)] + #![allow(clippy::dbg_macro)] #![allow(clippy::print_stderr)] #![allow(clippy::print_stdout)] #![allow(clippy::unwrap_used)] diff --git a/crates/tor-circmgr/src/path/dirpath.rs b/crates/tor-circmgr/src/path/dirpath.rs index 4bd9d0219..01e1caef8 100644 --- a/crates/tor-circmgr/src/path/dirpath.rs +++ b/crates/tor-circmgr/src/path/dirpath.rs @@ -80,8 +80,15 @@ impl DirPathBuilder { #[cfg(test)] mod test { - #![allow(clippy::unwrap_used)] + // @@ begin test lint list maintained by maint/add_warning @@ + #![allow(clippy::bool_assert_comparison)] #![allow(clippy::clone_on_copy)] + #![allow(clippy::dbg_macro)] + #![allow(clippy::print_stderr)] + #![allow(clippy::print_stdout)] + #![allow(clippy::unwrap_used)] + //! + use super::*; use crate::path::assert_same_path_when_owned; use crate::test::OptDummyGuardMgr; diff --git a/crates/tor-config/src/path.rs b/crates/tor-config/src/path.rs index 85be232d9..b1f151d5b 100644 --- a/crates/tor-config/src/path.rs +++ b/crates/tor-config/src/path.rs @@ -308,6 +308,15 @@ mod test { #[cfg(test)] mod test_serde { + // @@ begin test lint list maintained by maint/add_warning @@ + #![allow(clippy::bool_assert_comparison)] + #![allow(clippy::clone_on_copy)] + #![allow(clippy::dbg_macro)] + #![allow(clippy::print_stderr)] + #![allow(clippy::print_stdout)] + #![allow(clippy::unwrap_used)] + //! + use super::*; use std::ffi::OsString; use std::fmt::Debug; diff --git a/crates/tor-guardmgr/src/fallback/set.rs b/crates/tor-guardmgr/src/fallback/set.rs index f991f2112..ffdce1574 100644 --- a/crates/tor-guardmgr/src/fallback/set.rs +++ b/crates/tor-guardmgr/src/fallback/set.rs @@ -229,7 +229,15 @@ impl FallbackState { #[cfg(test)] mod test { + // @@ begin test lint list maintained by maint/add_warning @@ + #![allow(clippy::bool_assert_comparison)] + #![allow(clippy::clone_on_copy)] + #![allow(clippy::dbg_macro)] + #![allow(clippy::print_stderr)] + #![allow(clippy::print_stdout)] #![allow(clippy::unwrap_used)] + //! + use super::*; use crate::FirstHopId; use rand::Rng; diff --git a/crates/tor-proto/src/channel/padding.rs b/crates/tor-proto/src/channel/padding.rs index 8b1ec51e6..776b274bd 100644 --- a/crates/tor-proto/src/channel/padding.rs +++ b/crates/tor-proto/src/channel/padding.rs @@ -351,10 +351,16 @@ impl PreparedParameters { } #[cfg(test)] -#[allow(clippy::unwrap_used)] -#[allow(clippy::bool_assert_comparison)] -#[allow(clippy::print_stderr)] mod test { + // @@ begin test lint list maintained by maint/add_warning @@ + #![allow(clippy::bool_assert_comparison)] + #![allow(clippy::clone_on_copy)] + #![allow(clippy::dbg_macro)] + #![allow(clippy::print_stderr)] + #![allow(clippy::print_stdout)] + #![allow(clippy::unwrap_used)] + //! + use super::*; use futures::future::ready; use futures::select_biased; diff --git a/maint/add_warning b/maint/add_warning index c3f814aed..9f7e35743 100755 --- a/maint/add_warning +++ b/maint/add_warning @@ -49,6 +49,9 @@ WANT_LINTS = """ # ---------- list of lints to apply or disapply *in tests* ---------- TEST_LINTS = """ +#![allow(clippy::bool_assert_comparison)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::dbg_macro)] #![allow(clippy::print_stderr)] #![allow(clippy::print_stdout)] #![allow(clippy::unwrap_used)]