From 0222226b1628c4d5d686726e5e689a7afa82dcfe Mon Sep 17 00:00:00 2001 From: nemo Date: Wed, 5 May 2021 14:46:10 -0400 Subject: [PATCH] fix: remove build warnings --- fil-proofs-param/tests/paramfetch/session.rs | 3 ++- fil-proofs-param/tests/parampublish/support/session.rs | 5 +++-- filecoin-hashers/src/blake2s.rs | 3 ++- filecoin-hashers/src/poseidon.rs | 9 +++++---- filecoin-hashers/src/sha256.rs | 3 ++- filecoin-proofs/tests/mod.rs | 10 ++++++---- fr32/src/reader.rs | 5 ++++- storage-proofs-porep/src/stacked/vanilla/proof.rs | 5 +++-- 8 files changed, 27 insertions(+), 16 deletions(-) diff --git a/fil-proofs-param/tests/paramfetch/session.rs b/fil-proofs-param/tests/paramfetch/session.rs index ded9a591d8..f41d14536f 100644 --- a/fil-proofs-param/tests/paramfetch/session.rs +++ b/fil-proofs-param/tests/paramfetch/session.rs @@ -1,5 +1,6 @@ use std::fs::File; use std::io::{self, Read}; +use std::panic::panic_any; use std::path::{Path, PathBuf}; use failure::SyncFailure; @@ -63,7 +64,7 @@ impl ParamFetchSessionBuilder { /// Launch paramfetch in an environment configured by the builder. pub fn build(self) -> ParamFetchSession { let mut p = spawn_bash_with_retries(10, Some(self.session_timeout_ms)) - .unwrap_or_else(|err| panic!(err)); + .unwrap_or_else(|err| panic_any(err)); let cache_dir_path = format!("{:?}", self.cache_dir.path()); diff --git a/fil-proofs-param/tests/parampublish/support/session.rs b/fil-proofs-param/tests/parampublish/support/session.rs index e525e857d9..36d581891c 100644 --- a/fil-proofs-param/tests/parampublish/support/session.rs +++ b/fil-proofs-param/tests/parampublish/support/session.rs @@ -1,5 +1,6 @@ use std::fs::{read_dir, File}; use std::io::{self, Read, Write}; +use std::panic::panic_any; use std::path::{Path, PathBuf}; use failure::SyncFailure; @@ -116,12 +117,12 @@ impl ParamPublishSessionBuilder { /// Launch parampublish in an environment configured by the builder. pub fn build(self) -> (ParamPublishSession, Vec) { let mut p = spawn_bash_with_retries(10, Some(self.session_timeout_ms)) - .unwrap_or_else(|err| panic!(err)); + .unwrap_or_else(|err| panic_any(err)); let cache_dir_path = format!("{:?}", self.cache_dir.path()); let cache_contents: Vec = read_dir(&self.cache_dir) - .unwrap_or_else(|_| panic!("failed to read cache dir {:?}", self.cache_dir)) + .unwrap_or_else(|_| panic_any(format!("failed to read cache dir {:?}", self.cache_dir))) .map(|x| x.expect("failed to get dir entry")) .map(|x| x.path()) .collect(); diff --git a/filecoin-hashers/src/blake2s.rs b/filecoin-hashers/src/blake2s.rs index dfaf98ea8c..9bf1d1e4de 100644 --- a/filecoin-hashers/src/blake2s.rs +++ b/filecoin-hashers/src/blake2s.rs @@ -1,5 +1,6 @@ use std::fmt::{self, Debug, Formatter}; use std::hash::Hasher as StdHasher; +use std::panic::panic_any; use anyhow::ensure; use bellperson::{ @@ -125,7 +126,7 @@ impl Element for Blake2sDomain { fn from_slice(bytes: &[u8]) -> Self { match Blake2sDomain::try_from_bytes(bytes) { Ok(res) => res, - Err(err) => panic!(err), + Err(err) => panic_any(err), } } diff --git a/filecoin-hashers/src/poseidon.rs b/filecoin-hashers/src/poseidon.rs index c160f24313..db92a4a4bc 100644 --- a/filecoin-hashers/src/poseidon.rs +++ b/filecoin-hashers/src/poseidon.rs @@ -1,6 +1,7 @@ use std::cmp::Ordering; use std::hash::{Hash as StdHash, Hasher as StdHasher}; use std::mem::size_of; +use std::panic::panic_any; use std::slice; use anyhow::ensure; @@ -163,7 +164,7 @@ impl Element for PoseidonDomain { fn from_slice(bytes: &[u8]) -> Self { match PoseidonDomain::try_from_bytes(bytes) { Ok(res) => res, - Err(err) => panic!(err), + Err(err) => panic_any(err), } } @@ -217,7 +218,7 @@ fn shared_hash_frs(preimage: &[::Fr]) -> panic!("Unsupported arity for Poseidon hasher: {}", preimage.len()), + _ => panic_any(format!("Unsupported arity for Poseidon hasher: {}", preimage.len())), } } @@ -364,12 +365,12 @@ impl LightAlgorithm for PoseidonFunction { .enumerate() .map(|(i, x)| { ::Fr::from_repr(x.0) - .unwrap_or_else(|_| panic!("from_repr failure at {}", i)) + .unwrap_or_else(|_| panic_any(format!("from_repr failure at {}", i))) }) .collect::>(), ) .into(), - arity => panic!("unsupported arity {}", arity), + arity => panic_any(format!("unsupported arity {}", arity)), } } } diff --git a/filecoin-hashers/src/sha256.rs b/filecoin-hashers/src/sha256.rs index 398abd7faa..01efcd6eee 100644 --- a/filecoin-hashers/src/sha256.rs +++ b/filecoin-hashers/src/sha256.rs @@ -1,5 +1,6 @@ use std::fmt::{self, Debug, Formatter}; use std::hash::Hasher as StdHasher; +use std::panic::panic_any; use anyhow::ensure; use bellperson::{ @@ -148,7 +149,7 @@ impl Element for Sha256Domain { fn from_slice(bytes: &[u8]) -> Self { match Sha256Domain::try_from_bytes(bytes) { Ok(res) => res, - Err(err) => panic!(err), + Err(err) => panic_any(err), } } diff --git a/filecoin-proofs/tests/mod.rs b/filecoin-proofs/tests/mod.rs index 15d5ab948a..0be4d3ce1e 100644 --- a/filecoin-proofs/tests/mod.rs +++ b/filecoin-proofs/tests/mod.rs @@ -1,3 +1,5 @@ +use std::panic::panic_any; + use bellperson::bls::Fr; use ff::Field; use filecoin_proofs::{ @@ -49,10 +51,10 @@ fn test_verify_seal_fr32_validation() { assert!( haystack.contains(needle), - format!("\"{}\" did not contain \"{}\"", haystack, needle) + "\"{}\" did not contain \"{}\"", haystack, needle, ); } else { - panic!("should have failed comm_r to Fr32 conversion"); + panic_any("should have failed comm_r to Fr32 conversion"); } } @@ -85,10 +87,10 @@ fn test_verify_seal_fr32_validation() { assert!( haystack.contains(needle), - format!("\"{}\" did not contain \"{}\"", haystack, needle) + "\"{}\" did not contain \"{}\"", haystack, needle, ); } else { - panic!("should have failed comm_d to Fr32 conversion"); + panic_any("should have failed comm_d to Fr32 conversion"); } } } diff --git a/fr32/src/reader.rs b/fr32/src/reader.rs index 601a4c259c..78ea9239bc 100644 --- a/fr32/src/reader.rs +++ b/fr32/src/reader.rs @@ -2,7 +2,10 @@ use std::cmp::min; use std::io::{self, Read}; use std::mem::size_of; -use byte_slice_cast::{AsByteSlice, AsSliceOf}; +#[cfg(not(target_arch = "aarch64"))] +use byte_slice_cast::AsSliceOf; + +use byte_slice_cast::AsByteSlice; /// The number of Frs per Block. const NUM_FRS_PER_BLOCK: usize = 4; diff --git a/storage-proofs-porep/src/stacked/vanilla/proof.rs b/storage-proofs-porep/src/stacked/vanilla/proof.rs index 9189d6d7c0..61f325c086 100644 --- a/storage-proofs-porep/src/stacked/vanilla/proof.rs +++ b/storage-proofs-porep/src/stacked/vanilla/proof.rs @@ -1,5 +1,6 @@ use std::fs; use std::marker::PhantomData; +use std::panic::panic_any; use std::path::{Path, PathBuf}; use std::sync::Mutex; @@ -239,7 +240,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr let labeled_node = rcp.c_x.get_node_at_layer(layer)?; assert!( proof.verify(&pub_inputs.replica_id, &labeled_node), - format!("Invalid encoding proof generated at layer {}", layer) + "Invalid encoding proof generated at layer {}", layer, ); trace!("Valid encoding proof generated at layer {}", layer); } @@ -1238,7 +1239,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr )?; tree_c.root() } - _ => panic!("Unsupported column arity"), + _ => panic_any("Unsupported column arity"), }; info!("tree_c done");