Fix new clippy lints (#2036)

## Issue Addressed

NA

## Proposed Changes

Fixes new clippy lints in the whole project (mainly [manual_strip](https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip) and [unnecessary_lazy_evaluations](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations)). Furthermore, removes `to_string()` calls on literals when used with the `?`-operator.
This commit is contained in:
blacktemplar
2020-12-03 01:10:26 +00:00
parent d3f0a21436
commit d8cda2d86e
71 changed files with 314 additions and 364 deletions

View File

@@ -884,7 +884,7 @@ impl<T: EthSpec> BeaconState<T> {
self.eth1_data
.deposit_count
.checked_sub(self.eth1_deposit_index)
.ok_or_else(|| Error::InvalidDepositState {
.ok_or(Error::InvalidDepositState {
deposit_count: self.eth1_data.deposit_count,
deposit_index: self.eth1_deposit_index,
})

View File

@@ -56,7 +56,7 @@ impl CommitteeCache {
&seed[..],
false,
)
.ok_or_else(|| Error::UnableToShuffle)?;
.ok_or(Error::UnableToShuffle)?;
// The use of `NonZeroUsize` reduces the maximum number of possible validators by one.
if state.validators.len() == usize::max_value() {
@@ -148,7 +148,7 @@ impl CommitteeCache {
pub fn get_all_beacon_committees(&self) -> Result<Vec<BeaconCommittee>, Error> {
let initialized_epoch = self
.initialized_epoch
.ok_or_else(|| Error::CommitteeCacheUninitialized(None))?;
.ok_or(Error::CommitteeCacheUninitialized(None))?;
initialized_epoch.slot_iter(self.slots_per_epoch).try_fold(
Vec::with_capacity(self.slots_per_epoch as usize),

View File

@@ -419,7 +419,7 @@ impl ParallelValidatorTreeHash {
let validator = validators
.get(val_index)
.ok_or_else(|| Error::TreeHashCacheInconsistent)?;
.ok_or(Error::TreeHashCacheInconsistent)?;
validator
.recalculate_tree_hash_root(arena, cache)