Skip to content

Commit 00b775c

Browse files
committed
fix: clippy updates required by toolchain update
1 parent b57d0b2 commit 00b775c

File tree

7 files changed

+22
-14
lines changed

7 files changed

+22
-14
lines changed

fil-proofs-param/tests/paramfetch/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl ParamFetchSessionBuilder {
7777
s.push_str(&wl.join(","));
7878
s
7979
})
80-
.unwrap_or_else(|| "".to_string());
80+
.unwrap_or_default();
8181

8282
let json_argument = if self.manifest.is_some() {
8383
format!("--json={:?}", self.manifest.expect("missing manifest"))

fil-proofs-tooling/src/shared.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ pub fn create_replicas<Tree: 'static + MerkleTreeTrait>(
298298
let priv_infos = sealed_files
299299
.iter()
300300
.zip(seal_pre_commit_outputs.return_value.iter())
301-
.zip(cache_dirs.into_iter())
301+
.zip(cache_dirs)
302302
.map(|((sealed_file, seal_pre_commit_output), cache_dir)| {
303303
PrivateReplicaInfo::new(
304304
sealed_file.to_path_buf(),

filecoin-proofs/src/chunk_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<R: Read> Iterator for ChunkIterator<R> {
3838
match self.reader.read_many(&mut buffer) {
3939
Ok(bytes_read) if bytes_read == self.chunk_size => Some(Ok(buffer)),
4040
// A position of 0 indicates end of file.
41-
Ok(bytes_read) if bytes_read == 0 => None,
41+
Ok(0) => None,
4242
Ok(bytes_read) => Some(Ok(buffer[..bytes_read].to_vec())),
4343
Err(error) => Some(Err(error)),
4444
}

filecoin-proofs/src/types/private_replica_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<Tree: MerkleTreeTrait> Ord for PrivateReplicaInfo<Tree> {
7878

7979
impl<Tree: MerkleTreeTrait> PartialOrd for PrivateReplicaInfo<Tree> {
8080
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
81-
self.comm_r.as_ref().partial_cmp(other.comm_r.as_ref())
81+
Some(self.cmp(other))
8282
}
8383
}
8484

filecoin-proofs/tests/pieces.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,14 @@ fn test_verify_padded_pieces() {
266266
hash(&layer1[10], &layer1[11]), // 4
267267
];
268268

269-
let layer3 = vec![
269+
let layer3 = [
270270
hash(&layer2[0], &layer2[1]), // 8
271271
hash(&layer2[2], &layer2[3]), // 8
272272
layer2[4], // 8
273273
hash(&layer2[5], &layer2[6]), // 8
274274
];
275275

276-
let layer4 = vec![
276+
let layer4 = [
277277
hash(&layer3[0], &layer3[1]), // 16
278278
hash(&layer3[2], &layer3[3]), // 16
279279
];

storage-proofs-porep/src/stacked/vanilla/cache.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::collections::{BTreeMap, HashSet};
2+
use std::fmt::Write;
23
use std::fs::{remove_file, File};
34
use std::io;
45
use std::path::{Path, PathBuf};
@@ -250,7 +251,10 @@ impl ParentCache {
250251
drop(data);
251252

252253
let hash = hasher.finalize();
253-
digest_hex = hash.iter().map(|x| format!("{:01$x}", x, 2)).collect();
254+
digest_hex = hash.iter().fold(String::new(), |mut output, x| {
255+
let _ = write!(output, "{:01$x}", x, 2);
256+
output
257+
});
254258

255259
info!(
256260
"[open] parent cache: calculated consistency digest: {:?}",
@@ -343,7 +347,10 @@ impl ParentCache {
343347
let mut hasher = Sha256::new();
344348
hasher.update(&data);
345349
let hash = hasher.finalize();
346-
digest_hex = hash.iter().map(|x| format!("{:01$x}", x, 2)).collect();
350+
digest_hex = hash.iter().fold(String::new(), |mut output, x| {
351+
let _ = write!(output, "{:01$x}", x, 2);
352+
output
353+
});
347354
info!(
348355
"[generate] parent cache: generated consistency digest: {:?}",
349356
digest_hex

storage-proofs-porep/src/stacked/vanilla/create_label/multi.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ use std::convert::TryInto;
22
use std::marker::PhantomData;
33
use std::mem::{self, size_of};
44
use std::path::Path;
5+
use std::rc::Rc;
56
use std::sync::{
67
atomic::{AtomicU64, Ordering::SeqCst},
7-
Arc, MutexGuard,
8+
MutexGuard,
89
};
910
use std::thread;
1011
use std::time::Duration;
@@ -208,7 +209,7 @@ fn create_layer_labels(
208209
exp_labels: Option<&mut MmapMut>,
209210
num_nodes: u64,
210211
cur_layer: u32,
211-
core_group: Arc<Option<MutexGuard<'_, Vec<CoreIndex>>>>,
212+
core_group: Rc<Option<MutexGuard<'_, Vec<CoreIndex>>>>,
212213
) {
213214
info!("Creating labels for layer {}", cur_layer);
214215
// num_producers is the number of producer threads
@@ -458,14 +459,14 @@ pub fn create_labels_for_encoding<
458459

459460
let default_cache_size = DEGREE * 4 * cache_window_nodes;
460461

461-
let core_group = Arc::new(checkout_core_group());
462+
let core_group = Rc::new(checkout_core_group());
462463

463464
// When `_cleanup_handle` is dropped, the previous binding of thread will be restored.
464465
let _cleanup_handle = (*core_group).as_ref().map(|group| {
465466
// This could fail, but we will ignore the error if so.
466467
// It will be logged as a warning by `bind_core`.
467468
debug!("binding core in main thread");
468-
group.get(0).map(|core_index| bind_core(*core_index))
469+
group.first().map(|core_index| bind_core(*core_index))
469470
});
470471

471472
// NOTE: this means we currently keep 2x sector size around, to improve speed
@@ -556,14 +557,14 @@ pub fn create_labels_for_decoding<Tree: 'static + MerkleTreeTrait, T: AsRef<[u8]
556557

557558
let default_cache_size = DEGREE * 4 * cache_window_nodes;
558559

559-
let core_group = Arc::new(checkout_core_group());
560+
let core_group = Rc::new(checkout_core_group());
560561

561562
// When `_cleanup_handle` is dropped, the previous binding of thread will be restored.
562563
let _cleanup_handle = (*core_group).as_ref().map(|group| {
563564
// This could fail, but we will ignore the error if so.
564565
// It will be logged as a warning by `bind_core`.
565566
debug!("binding core in main thread");
566-
group.get(0).map(|core_index| bind_core(*core_index))
567+
group.first().map(|core_index| bind_core(*core_index))
567568
});
568569

569570
// NOTE: this means we currently keep 2x sector size around, to improve speed

0 commit comments

Comments
 (0)