Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve clippy lints #1337

Merged
merged 6 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fil-proofs-tooling/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//requires nightly, or later stable version
//#![warn(clippy::unwrap_used)]
#![deny(clippy::all, clippy::perf, clippy::correctness, rust_2018_idioms)]
#![warn(clippy::unwrap_used)]

pub mod measure;
pub mod metadata;
Expand Down
14 changes: 7 additions & 7 deletions filecoin-proofs/src/api/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pub fn generate_winning_post_with_vanilla<Tree: 'static + MerkleTreeTrait>(
partitions: None,
priority: post_config.priority,
};
let pub_params: compound_proof::PublicParams<fallback::FallbackPoSt<Tree>> =
let pub_params: compound_proof::PublicParams<'_, fallback::FallbackPoSt<'_, Tree>> =
fallback::FallbackPoStCompound::setup(&setup_params)?;
let groth_params = get_post_params::<Tree>(&post_config)?;

Expand Down Expand Up @@ -348,7 +348,7 @@ pub fn generate_winning_post<Tree: 'static + MerkleTreeTrait>(
partitions: None,
priority: post_config.priority,
};
let pub_params: compound_proof::PublicParams<fallback::FallbackPoSt<Tree>> =
let pub_params: compound_proof::PublicParams<'_, fallback::FallbackPoSt<'_, Tree>> =
fallback::FallbackPoStCompound::setup(&setup_params)?;
let groth_params = get_post_params::<Tree>(&post_config)?;

Expand Down Expand Up @@ -600,7 +600,7 @@ pub fn verify_winning_post<Tree: 'static + MerkleTreeTrait>(
partitions: None,
priority: false,
};
let pub_params: compound_proof::PublicParams<fallback::FallbackPoSt<Tree>> =
let pub_params: compound_proof::PublicParams<'_, fallback::FallbackPoSt<'_, Tree>> =
fallback::FallbackPoStCompound::setup(&setup_params)?;

let mut pub_sectors = Vec::with_capacity(param_sector_count);
Expand Down Expand Up @@ -656,7 +656,7 @@ pub fn verify_winning_post<Tree: 'static + MerkleTreeTrait>(
pub fn partition_vanilla_proofs<Tree: MerkleTreeTrait>(
post_config: &PoStConfig,
pub_params: &fallback::PublicParams,
pub_inputs: &fallback::PublicInputs<<Tree::Hasher as Hasher>::Domain>,
pub_inputs: &fallback::PublicInputs<'_, <Tree::Hasher as Hasher>::Domain>,
partition_count: usize,
vanilla_proofs: &[FallbackPoStSectorProof<Tree>],
) -> Result<Vec<VanillaProof<Tree>>> {
Expand Down Expand Up @@ -808,7 +808,7 @@ pub fn generate_window_post_with_vanilla<Tree: 'static + MerkleTreeTrait>(
None => 1,
};

let pub_params: compound_proof::PublicParams<fallback::FallbackPoSt<Tree>> =
let pub_params: compound_proof::PublicParams<'_, fallback::FallbackPoSt<'_, Tree>> =
fallback::FallbackPoStCompound::setup(&setup_params)?;
let groth_params = get_post_params::<Tree>(&post_config)?;

Expand Down Expand Up @@ -873,7 +873,7 @@ pub fn generate_window_post<Tree: 'static + MerkleTreeTrait>(
priority: post_config.priority,
};

let pub_params: compound_proof::PublicParams<fallback::FallbackPoSt<Tree>> =
let pub_params: compound_proof::PublicParams<'_, fallback::FallbackPoSt<'_, Tree>> =
fallback::FallbackPoStCompound::setup(&setup_params)?;
let groth_params = get_post_params::<Tree>(&post_config)?;

Expand Down Expand Up @@ -958,7 +958,7 @@ pub fn verify_window_post<Tree: 'static + MerkleTreeTrait>(
partitions,
priority: false,
};
let pub_params: compound_proof::PublicParams<fallback::FallbackPoSt<Tree>> =
let pub_params: compound_proof::PublicParams<'_, fallback::FallbackPoSt<'_, Tree>> =
fallback::FallbackPoStCompound::setup(&setup_params)?;

let pub_sectors: Vec<_> = replicas
Expand Down
8 changes: 4 additions & 4 deletions filecoin-proofs/src/api/seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ where
};

let compound_public_params = <StackedCompound<Tree, DefaultPieceHasher> as CompoundProof<
StackedDrg<Tree, DefaultPieceHasher>,
StackedDrg<'_, Tree, DefaultPieceHasher>,
_,
>>::setup(&compound_setup_params)?;

Expand Down Expand Up @@ -273,7 +273,7 @@ where
};

let compound_public_params = <StackedCompound<Tree, DefaultPieceHasher> as CompoundProof<
StackedDrg<Tree, DefaultPieceHasher>,
StackedDrg<'_, Tree, DefaultPieceHasher>,
_,
>>::setup(&compound_setup_params)?;

Expand Down Expand Up @@ -407,7 +407,7 @@ pub fn seal_commit_phase1<T: AsRef<Path>, Tree: 'static + MerkleTreeTrait>(
};

let compound_public_params = <StackedCompound<Tree, DefaultPieceHasher> as CompoundProof<
StackedDrg<Tree, DefaultPieceHasher>,
StackedDrg<'_, Tree, DefaultPieceHasher>,
_,
>>::setup(&compound_setup_params)?;

Expand Down Expand Up @@ -490,7 +490,7 @@ pub fn seal_commit_phase2<Tree: 'static + MerkleTreeTrait>(
};

let compound_public_params = <StackedCompound<Tree, DefaultPieceHasher> as CompoundProof<
StackedDrg<Tree, DefaultPieceHasher>,
StackedDrg<'_, Tree, DefaultPieceHasher>,
_,
>>::setup(&compound_setup_params)?;

Expand Down
12 changes: 6 additions & 6 deletions filecoin-proofs/src/caches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn get_stacked_params<Tree: 'static + MerkleTreeTrait>(

let parameters_generator = || {
<StackedCompound<Tree, DefaultPieceHasher> as CompoundProof<
StackedDrg<Tree, DefaultPieceHasher>,
StackedDrg<'_, Tree, DefaultPieceHasher>,
_,
>>::groth_params::<rand::rngs::OsRng>(None, &public_params)
.map_err(Into::into)
Expand All @@ -113,7 +113,7 @@ pub fn get_post_params<Tree: 'static + MerkleTreeTrait>(

let parameters_generator = || {
<fallback::FallbackPoStCompound<Tree> as CompoundProof<
fallback::FallbackPoSt<Tree>,
fallback::FallbackPoSt<'_, Tree>,
fallback::FallbackPoStCircuit<Tree>,
>>::groth_params::<rand::rngs::OsRng>(None, &post_public_params)
.map_err(Into::into)
Expand All @@ -132,7 +132,7 @@ pub fn get_post_params<Tree: 'static + MerkleTreeTrait>(

let parameters_generator = || {
<fallback::FallbackPoStCompound<Tree> as CompoundProof<
fallback::FallbackPoSt<Tree>,
fallback::FallbackPoSt<'_, Tree>,
fallback::FallbackPoStCircuit<Tree>,
>>::groth_params::<rand::rngs::OsRng>(None, &post_public_params)
.map_err(Into::into)
Expand Down Expand Up @@ -160,7 +160,7 @@ pub fn get_stacked_verifying_key<Tree: 'static + MerkleTreeTrait>(

let vk_generator = || {
let vk = <StackedCompound<Tree, DefaultPieceHasher> as CompoundProof<
StackedDrg<Tree, DefaultPieceHasher>,
StackedDrg<'_, Tree, DefaultPieceHasher>,
_,
>>::verifying_key::<rand::rngs::OsRng>(None, &public_params)?;
Ok(bellperson::groth16::prepare_verifying_key(&vk))
Expand All @@ -184,7 +184,7 @@ pub fn get_post_verifying_key<Tree: 'static + MerkleTreeTrait>(

let vk_generator = || {
let vk = <fallback::FallbackPoStCompound<Tree> as CompoundProof<
fallback::FallbackPoSt<Tree>,
fallback::FallbackPoSt<'_, Tree>,
fallback::FallbackPoStCircuit<Tree>,
>>::verifying_key::<rand::rngs::OsRng>(
None, &post_public_params
Expand All @@ -205,7 +205,7 @@ pub fn get_post_verifying_key<Tree: 'static + MerkleTreeTrait>(

let vk_generator = || {
let vk = <fallback::FallbackPoStCompound<Tree> as CompoundProof<
fallback::FallbackPoSt<Tree>,
fallback::FallbackPoSt<'_, Tree>,
fallback::FallbackPoStCircuit<Tree>,
>>::verifying_key::<rand::rngs::OsRng>(
None, &post_public_params
Expand Down
7 changes: 2 additions & 5 deletions filecoin-proofs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![deny(clippy::all, clippy::perf, clippy::correctness)]

//requires nightly, or later stable version
//#![warn(clippy::unwrap_used)]
#![deny(clippy::all, clippy::perf, clippy::correctness, rust_2018_idioms)]
#![warn(clippy::unwrap_used)]

mod api;
mod caches;
Expand All @@ -13,7 +11,6 @@ pub mod fr32_reader;
pub mod param;
pub mod parameters;
pub mod pieces;
pub mod serde_big_array;
pub mod types;

pub use self::api::*;
Expand Down
72 changes: 0 additions & 72 deletions filecoin-proofs/src/serde_big_array.rs

This file was deleted.

2 changes: 1 addition & 1 deletion filecoin-proofs/src/types/piece_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct PieceInfo {
}

impl fmt::Debug for PieceInfo {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("PieceInfo")
.field("commitment", &hex::encode(&self.commitment))
.field("size", &self.size)
Expand Down
2 changes: 1 addition & 1 deletion filecoin-proofs/src/types/porep_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl PoRepConfig {

Ok(
<StackedCompound<Tree, DefaultPieceHasher> as CacheableParameters<
StackedCircuit<Tree, DefaultPieceHasher>,
StackedCircuit<'_, Tree, DefaultPieceHasher>,
_,
>>::cache_identifier(&params),
)
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs/core/src/cache_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum CacheKey {
}

impl fmt::Display for CacheKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
CacheKey::PAux => write!(f, "p_aux"),
CacheKey::TAux => write!(f, "t_aux"),
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs/core/src/gadgets/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum Root<E: Engine> {
}

impl<E: Engine> fmt::Debug for Root<E> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Root::Var(num) => write!(f, "Root::Var({:?})", num.get_value()),
Root::Val(val) => write!(f, "Root::Val({:?})", val),
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs/core/src/hasher/blake2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl PartialEq for Blake2sFunction {
impl Eq for Blake2sFunction {}

impl fmt::Debug for Blake2sFunction {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Blake2sFunction({:?})", self.0)
}
}
Expand Down
11 changes: 7 additions & 4 deletions storage-proofs/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#![deny(clippy::all, clippy::perf, clippy::correctness)]
#![deny(clippy::all, clippy::perf, clippy::correctness, rust_2018_idioms)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::unreadable_literal)]
#![allow(clippy::type_repetition_in_bounds)]
//requires nightly, or later stable version
//#![warn(clippy::unwrap_used)]
#![warn(clippy::unwrap_used)]

#[macro_use]
pub mod test_helper;
Expand Down Expand Up @@ -48,6 +47,10 @@ pub fn is_legacy_porep_id(porep_id: PoRepID) -> bool {
// Of course, it happens to be the case that only the 'legacy' ids in question can ever satisfy
// this predicate, so the distinction is somewhat moot. However, for the sake of clarity in any future
// use of `porep_id`, we should pay close attention to this.
let id = u64::from_le_bytes(porep_id[..8].try_into().unwrap());
let id = u64::from_le_bytes(
porep_id[..8]
.try_into()
.expect("8 bytes is always a valid u64"),
);
id <= MAX_LEGACY_POREP_REGISTERED_PROOF_ID
}
2 changes: 1 addition & 1 deletion storage-proofs/core/src/merkle/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl<H: Hasher, Arity: PoseidonArity> InclusionPath<H, Arity> {
self.path.is_empty()
}

pub fn iter(&self) -> std::slice::Iter<PathElement<H, Arity>> {
pub fn iter(&self) -> std::slice::Iter<'_, PathElement<H, Arity>> {
self.path.iter()
}

Expand Down
2 changes: 1 addition & 1 deletion storage-proofs/core/src/por.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct PublicInputs<T: Domain> {

/// The inputs that are only available to the prover.
#[derive(Debug)]
pub struct PrivateInputs<'a, Tree: 'a + MerkleTreeTrait> {
pub struct PrivateInputs<'a, Tree: MerkleTreeTrait> {
/// The data of the leaf.
pub leaf: <Tree::Hasher as Hasher>::Domain,
/// The underlying merkle tree.
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs/core/src/sector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl From<SectorId> for Fr {
}

impl fmt::Display for SectorId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "SectorId({})", self.0)
}
}
Expand Down
2 changes: 1 addition & 1 deletion storage-proofs/porep/src/drg/compound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ where

fn circuit(
public_inputs: &<DrgPoRep<'a, H, G> as ProofScheme<'a>>::PublicInputs,
component_private_inputs: <DrgPoRepCircuit<H> as CircuitComponent>::ComponentPrivateInputs,
component_private_inputs: <DrgPoRepCircuit<'_, H> as CircuitComponent>::ComponentPrivateInputs,
proof: &<DrgPoRep<'a, H, G> as ProofScheme<'a>>::Proof,
public_params: &<DrgPoRep<'a, H, G> as ProofScheme<'a>>::PublicParams,
_partition_k: Option<usize>,
Expand Down
4 changes: 2 additions & 2 deletions storage-proofs/porep/src/drg/vanilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct PublicInputs<T: Domain> {
}

#[derive(Debug)]
pub struct PrivateInputs<'a, H: 'a + Hasher> {
pub struct PrivateInputs<'a, H: Hasher> {
pub tree_d: &'a BinaryMerkleTree<H>,
pub tree_r: &'a BinaryLCMerkleTree<H>,
pub tree_r_config_rows_to_discard: usize,
Expand Down Expand Up @@ -225,7 +225,7 @@ impl<'a, H: Hasher> From<&'a Proof<H>> for Proof<H> {
#[derive(Default)]
pub struct DrgPoRep<'a, H, G>
where
H: 'a + Hasher,
H: Hasher,
G: 'a + Graph<H>,
{
_h: PhantomData<&'a H>,
Expand Down
5 changes: 2 additions & 3 deletions storage-proofs/porep/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//requires nightly, or later stable version
//#![warn(clippy::unwrap_used)]

#![deny(clippy::all, clippy::perf, clippy::correctness, rust_2018_idioms)]
#![warn(clippy::unwrap_used)]
#![cfg_attr(target_arch = "aarch64", feature(stdsimd))]

pub mod drg;
Expand Down
Loading