From 4c91c00c0e0fbfb13f5fb2ab2e33e9b7688ca8cf Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Fri, 26 Feb 2021 11:10:30 +1100 Subject: [PATCH] Lint for sum and product in consensus code --- consensus/state_processing/clippy.toml | 5 +++++ consensus/state_processing/src/lib.rs | 1 + consensus/types/clippy.toml | 5 +++++ consensus/types/src/beacon_state/tree_hash_cache.rs | 1 + consensus/types/src/lib.rs | 1 + 5 files changed, 13 insertions(+) create mode 100644 consensus/state_processing/clippy.toml create mode 100644 consensus/types/clippy.toml diff --git a/consensus/state_processing/clippy.toml b/consensus/state_processing/clippy.toml new file mode 100644 index 00000000000..e23d2ed0520 --- /dev/null +++ b/consensus/state_processing/clippy.toml @@ -0,0 +1,5 @@ +# Disallow sum and product methods which are prone to overflow. +disallowed-methods = [ + "core::iter::traits::iterator::Iterator::sum", + "core::iter::traits::iterator::Iterator::product", +] diff --git a/consensus/state_processing/src/lib.rs b/consensus/state_processing/src/lib.rs index 4a04c024400..3ae90f885e7 100644 --- a/consensus/state_processing/src/lib.rs +++ b/consensus/state_processing/src/lib.rs @@ -1,4 +1,5 @@ #![deny(clippy::integer_arithmetic)] +#![deny(clippy::disallowed_method)] #[macro_use] mod macros; diff --git a/consensus/types/clippy.toml b/consensus/types/clippy.toml new file mode 100644 index 00000000000..e23d2ed0520 --- /dev/null +++ b/consensus/types/clippy.toml @@ -0,0 +1,5 @@ +# Disallow sum and product methods which are prone to overflow. +disallowed-methods = [ + "core::iter::traits::iterator::Iterator::sum", + "core::iter::traits::iterator::Iterator::product", +] diff --git a/consensus/types/src/beacon_state/tree_hash_cache.rs b/consensus/types/src/beacon_state/tree_hash_cache.rs index ddd85bb93ff..ee8cfb2dd55 100644 --- a/consensus/types/src/beacon_state/tree_hash_cache.rs +++ b/consensus/types/src/beacon_state/tree_hash_cache.rs @@ -1,4 +1,5 @@ #![allow(clippy::integer_arithmetic)] +#![allow(clippy::disallowed_method)] use super::Error; use crate::{BeaconState, EthSpec, Hash256, Slot, Unsigned, Validator}; diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index be86daad56d..5016b6f1305 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -4,6 +4,7 @@ #![recursion_limit = "128"] // Clippy lint set up #![deny(clippy::integer_arithmetic)] +#![deny(clippy::disallowed_method)] #[macro_use] extern crate lazy_static;