From 000c7b4bc6202186a167bb451c1a2a24dc670ba9 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Fri, 25 Aug 2023 01:08:13 -0300 Subject: [PATCH] fix(clippy): Fix clippy and rustfmt after last releases today (#7381) * fix clippy and rustfmt after last releases today * Ignore clippy::arc_with_non_send_sync false positives in proptest code only * Remove .cargo/config.toml changes that didn't work --------- Co-authored-by: teor --- zebra-chain/src/lib.rs | 10 ++++++++++ zebra-consensus/src/lib.rs | 10 ++++++++++ zebra-network/src/address_book.rs | 4 ++-- zebra-network/src/lib.rs | 10 ++++++++++ zebra-state/src/lib.rs | 10 ++++++++++ zebra-state/src/service/chain_tip/tests.rs | 2 ++ zebrad/src/lib.rs | 10 ++++++++++ 7 files changed, 54 insertions(+), 2 deletions(-) diff --git a/zebra-chain/src/lib.rs b/zebra-chain/src/lib.rs index eee58e7e9..a7e7b1cf6 100644 --- a/zebra-chain/src/lib.rs +++ b/zebra-chain/src/lib.rs @@ -8,6 +8,16 @@ #![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_chain")] // Required by bitvec! macro #![recursion_limit = "256"] +// +// Rust 1.72 has a false positive when nested generics are used inside Arc. +// This makes the `arc_with_non_send_sync` lint trigger on a lot of proptest code. +// +// TODO: remove this allow when Rust 1.73 is stable, because this lint bug is fixed in that release: +// +#![cfg_attr( + any(test, feature = "proptest-impl"), + allow(clippy::arc_with_non_send_sync) +)] #[macro_use] extern crate bitflags; diff --git a/zebra-consensus/src/lib.rs b/zebra-consensus/src/lib.rs index 7b8f58f9c..28abdda4e 100644 --- a/zebra-consensus/src/lib.rs +++ b/zebra-consensus/src/lib.rs @@ -33,6 +33,16 @@ #![doc(html_favicon_url = "https://zfnd.org/wp-content/uploads/2022/03/zebra-favicon-128.png")] #![doc(html_logo_url = "https://zfnd.org/wp-content/uploads/2022/03/zebra-icon.png")] #![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_consensus")] +// +// Rust 1.72 has a false positive when nested generics are used inside Arc. +// This makes the `arc_with_non_send_sync` lint trigger on a lot of proptest code. +// +// TODO: remove this allow when Rust 1.73 is stable, because this lint bug is fixed in that release: +// +#![cfg_attr( + any(test, feature = "proptest-impl"), + allow(clippy::arc_with_non_send_sync) +)] mod block; mod checkpoint; diff --git a/zebra-network/src/address_book.rs b/zebra-network/src/address_book.rs index de05b39bd..548c96aa0 100644 --- a/zebra-network/src/address_book.rs +++ b/zebra-network/src/address_book.rs @@ -354,7 +354,7 @@ impl AddressBook { /// See [`AddressBook::is_ready_for_connection_attempt_with_ip`] for more details. fn should_update_most_recent_by_ip(&self, updated: MetaAddr) -> bool { let Some(most_recent_by_ip) = self.most_recent_by_ip.as_ref() else { - return false + return false; }; if let Some(previous) = most_recent_by_ip.get(&updated.addr.ip()) { @@ -369,7 +369,7 @@ impl AddressBook { /// The entry is checked for an exact match to the IP and port of `addr`. fn should_remove_most_recent_by_ip(&self, addr: PeerSocketAddr) -> bool { let Some(most_recent_by_ip) = self.most_recent_by_ip.as_ref() else { - return false + return false; }; if let Some(previous) = most_recent_by_ip.get(&addr.ip()) { diff --git a/zebra-network/src/lib.rs b/zebra-network/src/lib.rs index 97eafef65..006045384 100644 --- a/zebra-network/src/lib.rs +++ b/zebra-network/src/lib.rs @@ -132,6 +132,16 @@ #![doc(html_favicon_url = "https://zfnd.org/wp-content/uploads/2022/03/zebra-favicon-128.png")] #![doc(html_logo_url = "https://zfnd.org/wp-content/uploads/2022/03/zebra-icon.png")] #![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_network")] +// +// Rust 1.72 has a false positive when nested generics are used inside Arc. +// This makes the `arc_with_non_send_sync` lint trigger on a lot of proptest code. +// +// TODO: remove this allow when Rust 1.73 is stable, because this lint bug is fixed in that release: +// +#![cfg_attr( + any(test, feature = "proptest-impl"), + allow(clippy::arc_with_non_send_sync) +)] #[macro_use] extern crate pin_project; diff --git a/zebra-state/src/lib.rs b/zebra-state/src/lib.rs index eedb90d13..e866de05d 100644 --- a/zebra-state/src/lib.rs +++ b/zebra-state/src/lib.rs @@ -11,6 +11,16 @@ #![doc(html_favicon_url = "https://zfnd.org/wp-content/uploads/2022/03/zebra-favicon-128.png")] #![doc(html_logo_url = "https://zfnd.org/wp-content/uploads/2022/03/zebra-icon.png")] #![doc(html_root_url = "https://doc.zebra.zfnd.org/zebra_state")] +// +// Rust 1.72 has a false positive when nested generics are used inside Arc. +// This makes the `arc_with_non_send_sync` lint trigger on a lot of proptest code. +// +// TODO: remove this allow when Rust 1.73 is stable, because this lint bug is fixed in that release: +// +#![cfg_attr( + any(test, feature = "proptest-impl"), + allow(clippy::arc_with_non_send_sync) +)] #[macro_use] extern crate tracing; diff --git a/zebra-state/src/service/chain_tip/tests.rs b/zebra-state/src/service/chain_tip/tests.rs index cc95d9d45..962cc1fdc 100644 --- a/zebra-state/src/service/chain_tip/tests.rs +++ b/zebra-state/src/service/chain_tip/tests.rs @@ -1,2 +1,4 @@ +//! Tests for state ChainTip traits and types. + mod prop; mod vectors; diff --git a/zebrad/src/lib.rs b/zebrad/src/lib.rs index 8bac85533..fbfe58eab 100644 --- a/zebrad/src/lib.rs +++ b/zebrad/src/lib.rs @@ -100,6 +100,16 @@ // Tracing causes false positives on this lint: // https://github.com/tokio-rs/tracing/issues/553 #![allow(clippy::cognitive_complexity)] +// +// Rust 1.72 has a false positive when nested generics are used inside Arc. +// This makes the `arc_with_non_send_sync` lint trigger on a lot of proptest code. +// +// TODO: remove this allow when Rust 1.73 is stable, because this lint bug is fixed in that release: +// +#![cfg_attr( + any(test, feature = "proptest-impl"), + allow(clippy::arc_with_non_send_sync) +)] #[macro_use] extern crate tracing;