Add various fixes to clippy lints

Thou shalt appease clippy
This commit is contained in:
Paul Hauner
2019-06-10 11:01:25 -04:00
parent a9284bec18
commit e550c0218f
37 changed files with 72 additions and 82 deletions

View File

@@ -422,7 +422,7 @@ impl<T: EthSpec> BeaconState<T> {
};
let effective_balance = self.validator_registry[candidate_index].effective_balance;
if (effective_balance * MAX_RANDOM_BYTE)
>= (spec.max_effective_balance * random_byte as u64)
>= (spec.max_effective_balance * u64::from(random_byte))
{
break candidate_index;
}

View File

@@ -162,7 +162,6 @@ impl CommitteeCache {
let i = self.shuffled_position(validator_index)?;
(0..self.committee_count)
.into_iter()
.map(|nth_committee| (nth_committee, self.compute_committee_range(nth_committee)))
.find(|(_, range)| {
if let Some(range) = range {

View File

@@ -174,7 +174,7 @@ impl ChainSpec {
/*
* Time parameters
*/
genesis_time: u32::max_value() as u64,
genesis_time: u64::from(u32::max_value()),
seconds_per_slot: 6,
min_attestation_inclusion_delay: 4,
min_seed_lookahead: Epoch::new(1),

View File

@@ -77,7 +77,7 @@ impl Epoch {
/// Position of some slot inside an epoch, if any.
///
/// E.g., the first `slot` in `epoch` is at position `0`.
pub fn position(&self, slot: Slot, slots_per_epoch: u64) -> Option<usize> {
pub fn position(self, slot: Slot, slots_per_epoch: u64) -> Option<usize> {
let start = self.start_slot(slots_per_epoch);
let end = self.end_slot(slots_per_epoch);

View File

@@ -271,7 +271,7 @@ fn build_proposer_slashing<T: EthSpec>(
Signature::new(message, domain, secret_key)
};
TestingProposerSlashingBuilder::double_vote::<T, _>(validator_index, signer, spec)
TestingProposerSlashingBuilder::double_vote::<T, _>(validator_index, signer)
}
/// Builds an `AttesterSlashing` for some `validator_indices`.

View File

@@ -17,7 +17,7 @@ impl TestingProposerSlashingBuilder {
/// - `domain: Domain`
///
/// Where domain is a domain "constant" (e.g., `spec.domain_attestation`).
pub fn double_vote<T, F>(proposer_index: u64, signer: F, spec: &ChainSpec) -> ProposerSlashing
pub fn double_vote<T, F>(proposer_index: u64, signer: F) -> ProposerSlashing
where
T: EthSpec,
F: Fn(u64, &[u8], Epoch, Domain) -> Signature,

View File

@@ -13,6 +13,7 @@ where
u8::from_str_radix(&s.as_str()[2..], 16).map_err(D::Error::custom)
}
#[allow(clippy::trivially_copy_pass_by_ref)] // Serde requires the `byte` to be a ref.
pub fn u8_to_hex_str<S>(byte: &u8, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,