Skip to content

Commit 6e53c05

Browse files
committed
fix: additional clippy updates
1 parent e266b9c commit 6e53c05

File tree

17 files changed

+36
-22
lines changed

17 files changed

+36
-22
lines changed

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
println!("cargo::rustc-check-cfg=cfg(nightly)");
2+
13
fn is_compiled_for_64_bit_arch() -> bool {
24
cfg!(target_pointer_width = "64")
35
}

fil-proofs-param/src/bin/paramfetch.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ struct FetchProgress<R> {
5151

5252
impl<R: Read> Read for FetchProgress<R> {
5353
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
54-
self.reader.read(buf).map(|n| {
55-
self.progress_bar.add(n as u64);
56-
n
54+
self.reader.read(buf).inspect(|n| {
55+
self.progress_bar.add(*n as u64);
5756
})
5857
}
5958
}

fil-proofs-tooling/src/bin/benchy/porep.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn run_pre_commit_phases<Tree: 'static + MerkleTreeTrait>(
9494
OpenOptions::new().read(true).write(true).open(&staged_file_path)
9595
} else {
9696
info!("*** Creating staged file");
97-
OpenOptions::new().read(true).write(true).create(true).open(&staged_file_path)
97+
OpenOptions::new().read(true).write(true).create(true).truncate(true).open(&staged_file_path)
9898
}?;
9999

100100
let sealed_file_path = cache_dir.join(SEALED_FILE);
@@ -103,7 +103,7 @@ fn run_pre_commit_phases<Tree: 'static + MerkleTreeTrait>(
103103
OpenOptions::new().read(true).write(true).open(&sealed_file_path)
104104
} else {
105105
info!("*** Creating sealed file");
106-
OpenOptions::new().read(true).write(true).create(true).open(&sealed_file_path)
106+
OpenOptions::new().read(true).write(true).create(true).truncate(true).open(&sealed_file_path)
107107
}?;
108108

109109
let sector_size_unpadded_bytes_amount =
@@ -120,7 +120,7 @@ fn run_pre_commit_phases<Tree: 'static + MerkleTreeTrait>(
120120
.collect();
121121

122122
info!("*** Created piece file");
123-
let mut piece_file = OpenOptions::new().read(true).write(true).create(true).open(&piece_file_path)?;
123+
let mut piece_file = OpenOptions::new().read(true).write(true).create(true).truncate(true).open(&piece_file_path)?;
124124
piece_file.write_all(&piece_bytes)?;
125125
piece_file.sync_all()?;
126126
piece_file.rewind()?;

fil-proofs-tooling/src/bin/benchy/window_post.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn run_pre_commit_phases<Tree: 'static + MerkleTreeTrait>(
101101
OpenOptions::new().read(true).write(true).open(&staged_file_path)
102102
} else {
103103
info!("*** Creating staged file");
104-
OpenOptions::new().read(true).write(true).create(true).open(&staged_file_path)
104+
OpenOptions::new().read(true).write(true).create(true).truncate(true).open(&staged_file_path)
105105
}?;
106106

107107
let sealed_file_path = cache_dir.join(SEALED_FILE);
@@ -110,7 +110,7 @@ fn run_pre_commit_phases<Tree: 'static + MerkleTreeTrait>(
110110
OpenOptions::new().read(true).write(true).open(&sealed_file_path)
111111
} else {
112112
info!("*** Creating sealed file");
113-
OpenOptions::new().read(true).write(true).create(true).open(&sealed_file_path)
113+
OpenOptions::new().read(true).write(true).create(true).truncate(true).open(&sealed_file_path)
114114
}?;
115115

116116
let sector_size_unpadded_bytes_amount =
@@ -128,7 +128,7 @@ fn run_pre_commit_phases<Tree: 'static + MerkleTreeTrait>(
128128
.collect();
129129

130130
info!("*** Created piece file");
131-
let mut piece_file = OpenOptions::new().read(true).write(true).create(true).open(&piece_file_path)?;
131+
let mut piece_file = OpenOptions::new().read(true).write(true).create(true).truncate(true).open(&piece_file_path)?;
132132
piece_file.write_all(&piece_bytes)?;
133133
piece_file.sync_all()?;
134134
piece_file.rewind()?;

fil-proofs-tooling/src/bin/benchy/winning_post.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ pub fn run_fallback_post_bench<Tree: 'static + MerkleTreeTrait>(
6363
create_replica::<Tree>(sector_size, fake_replica, api_version, api_features);
6464

6565
// Store the replica's private and publicly facing info for proving and verifying respectively.
66-
let pub_replica_info = vec![(sector_id, replica_output.public_replica_info.clone())];
67-
let priv_replica_info = vec![(sector_id, replica_output.private_replica_info.clone())];
66+
let pub_replica_info = [(sector_id, replica_output.public_replica_info.clone())];
67+
let priv_replica_info = [(sector_id, replica_output.private_replica_info.clone())];
6868

6969
let post_config = PoStConfig {
7070
sector_size: sector_size.into(),

fil-proofs-tooling/src/bin/gpu-cpu-test/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn thread_fun(
104104
) -> RunInfo {
105105
let timing = Instant::now();
106106
let mut iteration = 0;
107-
while iteration < std::u8::MAX {
107+
while iteration < u8::MAX {
108108
info!("iter {}", iteration);
109109

110110
// This is the higher priority proof, get it on the GPU even if there is one running

filecoin-proofs/src/api/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ where
367367
/// # Arguments
368368
///
369369
/// * `source` - a readable source of unprocessed piece bytes. The piece's commitment will be
370-
/// generated for the bytes read from the source plus any added padding.
370+
/// generated for the bytes read from the source plus any added padding.
371371
/// * `piece_size` - the number of unpadded user-bytes which can be read from source before EOF.
372372
pub fn generate_piece_commitment<T: Read>(
373373
source: T,

filecoin-proofs/tests/api.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,15 +1454,15 @@ fn winning_post<Tree: 'static + MerkleTreeTrait>(
14541454
assert_eq!(challenged_sectors.len(), sector_count);
14551455
assert_eq!(challenged_sectors[0], 0); // with a sector_count of 1, the only valid index is 0
14561456

1457-
let pub_replicas = vec![(sector_id, PublicReplicaInfo::new(comm_r)?)];
1457+
let pub_replicas = [(sector_id, PublicReplicaInfo::new(comm_r)?)];
14581458
let private_replica_info =
14591459
PrivateReplicaInfo::new(replica.path().into(), comm_r, cache_dir.path().into())?;
14601460

14611461
/////////////////////////////////////////////
14621462
// The following methods of proof generation are functionally equivalent:
14631463
// 1)
14641464
//
1465-
let priv_replicas = vec![(sector_id, private_replica_info.clone())];
1465+
let priv_replicas = [(sector_id, private_replica_info.clone())];
14661466
let proof = generate_winning_post::<Tree>(&config, &randomness, &priv_replicas[..], prover_id)?;
14671467

14681468
let valid =
@@ -2629,6 +2629,7 @@ fn create_seal_for_upgrade<R: Rng, Tree: 'static + MerkleTreeTrait<Hasher = Tree
26292629
.read(true)
26302630
.write(true)
26312631
.create(true)
2632+
.truncate(true)
26322633
.open(new_sealed_sector_file.path())
26332634
.with_context(|| format!("could not open path={:?}", new_sealed_sector_file.path()))?;
26342635
f_sealed_sector.set_len(new_replica_target_len)?;
@@ -2734,6 +2735,7 @@ fn create_seal_for_upgrade<R: Rng, Tree: 'static + MerkleTreeTrait<Hasher = Tree
27342735
.read(true)
27352736
.write(true)
27362737
.create(true)
2738+
.truncate(true)
27372739
.open(decoded_sector_file.path())
27382740
.with_context(|| format!("could not open path={:?}", decoded_sector_file.path()))?;
27392741
f_decoded_sector.set_len(decoded_sector_target_len)?;
@@ -2780,6 +2782,7 @@ fn create_seal_for_upgrade<R: Rng, Tree: 'static + MerkleTreeTrait<Hasher = Tree
27802782
.read(true)
27812783
.write(true)
27822784
.create(true)
2785+
.truncate(true)
27832786
.open(remove_encoded_file.path())
27842787
.with_context(|| format!("could not open path={:?}", remove_encoded_file.path()))?;
27852788
f_remove_encoded.set_len(remove_encoded_target_len)?;
@@ -2895,6 +2898,7 @@ fn create_seal_for_upgrade_aggregation<
28952898
.read(true)
28962899
.write(true)
28972900
.create(true)
2901+
.truncate(true)
28982902
.open(new_sealed_sector_file.path())
28992903
.with_context(|| format!("could not open path={:?}", new_sealed_sector_file.path()))?;
29002904
f_sealed_sector.set_len(new_replica_target_len)?;

fr32/src/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub enum Error {
1212
/// Invariants:
1313
/// - Value of each 32-byte chunks MUST represent valid Frs.
1414
/// - Total length must be a multiple of 32.
15-
/// That is to say: each 32-byte chunk taken alone must be a valid Fr32.
15+
/// That is to say: each 32-byte chunk taken alone must be a valid Fr32.
1616
pub type Fr32Vec = Vec<u8>;
1717

1818
/// Array whose little-endian value represents an Fr.

fr32/src/padding.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ need to handle the potential bit-level misalignments:
563563
// offset and num_bytes are based on the unpadded data, so
564564
// if [0, 1, ..., 255] was the original unpadded data, offset 3 and len 4 would return
565565
// [3, 4, 5, 6].
566+
#[allow(clippy::multiple_bound_locations)]
566567
pub fn write_unpadded<W: ?Sized>(
567568
source: &[u8],
568569
target: &mut W,
@@ -630,6 +631,7 @@ The reader will generally operate with bit precision, even if the padded
630631
layout is byte-aligned (no extra bits) the data inside it isn't (since
631632
we pad at the bit-level).
632633
**/
634+
#[allow(clippy::multiple_bound_locations)]
633635
fn write_unpadded_aux<W: ?Sized>(
634636
padding_map: &PaddingMap,
635637
source: &[u8],

0 commit comments

Comments
 (0)