From 71fd0b42f2ac06073aaf23c4148c7beb036ef555 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Fri, 12 Aug 2022 00:56:39 +0000 Subject: [PATCH] Fix lints for Rust 1.63 (#3459) ## Issue Addressed N/A ## Proposed Changes Fix clippy lints for latest rust version 1.63. I have allowed the [derive_partial_eq_without_eq](https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq) lint as satisfying this lint would result in more code that we might not want and I feel it's not required. Happy to fix this lint across lighthouse if required though. --- Makefile | 1 + beacon_node/http_api/src/block_id.rs | 4 ++-- beacon_node/store/src/iter.rs | 2 +- common/deposit_contract/build.rs | 10 ++++------ common/sensitive_url/src/lib.rs | 2 +- consensus/ssz_types/src/fixed_vector.rs | 2 +- consensus/ssz_types/src/variable_list.rs | 2 +- testing/state_transition_vectors/src/exit.rs | 1 + 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 55e987be8..df90ba3e7 100644 --- a/Makefile +++ b/Makefile @@ -142,6 +142,7 @@ lint: cargo clippy --workspace --tests -- \ -D clippy::fn_to_numeric_cast_any \ -D warnings \ + -A clippy::derive_partial_eq_without_eq \ -A clippy::from-over-into \ -A clippy::upper-case-acronyms \ -A clippy::vec-init-then-push diff --git a/beacon_node/http_api/src/block_id.rs b/beacon_node/http_api/src/block_id.rs index e41884904..5c785fe65 100644 --- a/beacon_node/http_api/src/block_id.rs +++ b/beacon_node/http_api/src/block_id.rs @@ -90,10 +90,10 @@ impl BlockId { .map_err(warp_utils::reject::beacon_chain_error)?; Ok((*root, execution_optimistic)) } else { - return Err(warp_utils::reject::custom_not_found(format!( + Err(warp_utils::reject::custom_not_found(format!( "beacon block with root {}", root - ))); + ))) } } } diff --git a/beacon_node/store/src/iter.rs b/beacon_node/store/src/iter.rs index 910979247..07c99e5a4 100644 --- a/beacon_node/store/src/iter.rs +++ b/beacon_node/store/src/iter.rs @@ -212,7 +212,7 @@ impl<'a, T: EthSpec, Hot: ItemStore, Cold: ItemStore> RootsIterator<'a, T, (Err(BeaconStateError::SlotOutOfBounds), Err(BeaconStateError::SlotOutOfBounds)) => { // Read a `BeaconState` from the store that has access to prior historical roots. if let Some(beacon_state) = - next_historical_root_backtrack_state(&*self.store, &self.beacon_state) + next_historical_root_backtrack_state(self.store, &self.beacon_state) .handle_unavailable()? { self.beacon_state = Cow::Owned(beacon_state); diff --git a/common/deposit_contract/build.rs b/common/deposit_contract/build.rs index ac05a53e3..cae1d480c 100644 --- a/common/deposit_contract/build.rs +++ b/common/deposit_contract/build.rs @@ -54,12 +54,10 @@ fn read_contract_file_from_url(url: Url) -> Result { .map_err(|e| format!("Respsonse is not a valid json {:?}", e))?; Ok(contract) } - Err(e) => { - return Err(format!( - "No abi file found. Failed to download from github: {:?}", - e - )) - } + Err(e) => Err(format!( + "No abi file found. Failed to download from github: {:?}", + e + )), } } } diff --git a/common/sensitive_url/src/lib.rs b/common/sensitive_url/src/lib.rs index aac4cb550..b6705eb60 100644 --- a/common/sensitive_url/src/lib.rs +++ b/common/sensitive_url/src/lib.rs @@ -46,7 +46,7 @@ impl Serialize for SensitiveUrl { where S: Serializer, { - serializer.serialize_str(&self.full.to_string()) + serializer.serialize_str(self.full.as_ref()) } } diff --git a/consensus/ssz_types/src/fixed_vector.rs b/consensus/ssz_types/src/fixed_vector.rs index ca5d40f14..5f7a4af96 100644 --- a/consensus/ssz_types/src/fixed_vector.rs +++ b/consensus/ssz_types/src/fixed_vector.rs @@ -353,7 +353,7 @@ mod test { let vec = vec![0, 2, 4, 6]; let fixed: FixedVector = FixedVector::from(vec); - assert_eq!(fixed.get(0), Some(&0)); + assert_eq!(fixed.first(), Some(&0)); assert_eq!(fixed.get(3), Some(&6)); assert_eq!(fixed.get(4), None); } diff --git a/consensus/ssz_types/src/variable_list.rs b/consensus/ssz_types/src/variable_list.rs index 5acf74608..49f8004b2 100644 --- a/consensus/ssz_types/src/variable_list.rs +++ b/consensus/ssz_types/src/variable_list.rs @@ -335,7 +335,7 @@ mod test { let vec = vec![0, 2, 4, 6]; let fixed: VariableList = VariableList::from(vec); - assert_eq!(fixed.get(0), Some(&0)); + assert_eq!(fixed.first(), Some(&0)); assert_eq!(fixed.get(3), Some(&6)); assert_eq!(fixed.get(4), None); } diff --git a/testing/state_transition_vectors/src/exit.rs b/testing/state_transition_vectors/src/exit.rs index 3e4bb7bf3..f485e1a26 100644 --- a/testing/state_transition_vectors/src/exit.rs +++ b/testing/state_transition_vectors/src/exit.rs @@ -15,6 +15,7 @@ struct ExitTest { validator_index: u64, exit_epoch: Epoch, state_epoch: Epoch, + #[allow(clippy::type_complexity)] state_modifier: Box)>, #[allow(clippy::type_complexity)] block_modifier: