From e800bdbcfbd147c80c5bc8bf6e23441524342e89 Mon Sep 17 00:00:00 2001 From: Cyril Plisko Date: Tue, 8 Aug 2023 11:04:08 +0300 Subject: [PATCH 1/5] clippy::needless_return --- .../peer_binary_protocol/src/extended/ut_metadata.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/peer_binary_protocol/src/extended/ut_metadata.rs b/crates/peer_binary_protocol/src/extended/ut_metadata.rs index d2f7be3..56d7924 100644 --- a/crates/peer_binary_protocol/src/extended/ut_metadata.rs +++ b/crates/peer_binary_protocol/src/extended/ut_metadata.rs @@ -132,12 +132,10 @@ impl<'a, ByteBuf: 'a> UtMetadata { } Ok(UtMetadata::Reject(message.piece)) } - other => { - return Err(MessageDeserializeError::Other(anyhow::anyhow!( - "unrecognized ut_metadata message type {}", - other - ))) - } + other => Err(MessageDeserializeError::Other(anyhow::anyhow!( + "unrecognized ut_metadata message type {}", + other + ))), } } } From e06d2ae1a8066e4f335e2a92b48465b059163a09 Mon Sep 17 00:00:00 2001 From: Cyril Plisko Date: Tue, 8 Aug 2023 11:08:14 +0300 Subject: [PATCH 2/5] clippy::redundant_locals --- crates/dht/src/dht.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/dht/src/dht.rs b/crates/dht/src/dht.rs index 88a9592..a1b23ba 100644 --- a/crates/dht/src/dht.rs +++ b/crates/dht/src/dht.rs @@ -498,7 +498,6 @@ impl DhtWorker { let mut futs = FuturesUnordered::new(); // bootstrap for addr in bootstrap_addrs.iter() { - let addr = addr; let this = &self; let in_tx = &in_tx; futs.push(async move { From 6b72d18a7b2ffea69d5a95219f1444a8c2afa2c1 Mon Sep 17 00:00:00 2001 From: Cyril Plisko Date: Tue, 8 Aug 2023 11:10:10 +0300 Subject: [PATCH 3/5] clippy::needless_pass_by_ref_mut --- crates/librqbit/src/torrent_manager.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/librqbit/src/torrent_manager.rs b/crates/librqbit/src/torrent_manager.rs index 6c5b961..a77d08c 100644 --- a/crates/librqbit/src/torrent_manager.rs +++ b/crates/librqbit/src/torrent_manager.rs @@ -160,7 +160,7 @@ fn make_lengths>( Lengths::new(total_length, torrent.piece_length, None) } -fn ensure_file_length(file: &mut File, length: u64) -> anyhow::Result<()> { +fn ensure_file_length(file: &File, length: u64) -> anyhow::Result<()> { Ok(file.set_len(length)?) } From 671b636f479f641d79a54dd775af68283601874c Mon Sep 17 00:00:00 2001 From: Cyril Plisko Date: Tue, 8 Aug 2023 11:13:07 +0300 Subject: [PATCH 4/5] clippy::unnecessary_mut_passed --- crates/librqbit/src/torrent_manager.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/librqbit/src/torrent_manager.rs b/crates/librqbit/src/torrent_manager.rs index a77d08c..d3826e8 100644 --- a/crates/librqbit/src/torrent_manager.rs +++ b/crates/librqbit/src/torrent_manager.rs @@ -237,7 +237,7 @@ impl TorrentManager { continue; } let now = Instant::now(); - if let Err(err) = ensure_file_length(&mut file.lock(), length) { + if let Err(err) = ensure_file_length(&file.lock(), length) { warn!( "Error setting length for file {:?} to {}: {:#?}", name, length, err From 548fd695d42e05f5e3af8a0266a450a542858e7d Mon Sep 17 00:00:00 2001 From: Cyril Plisko Date: Tue, 8 Aug 2023 11:13:48 +0300 Subject: [PATCH 5/5] clippy::manual_next_back --- crates/librqbit/src/chunk_tracker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/librqbit/src/chunk_tracker.rs b/crates/librqbit/src/chunk_tracker.rs index 47c306d..c013588 100644 --- a/crates/librqbit/src/chunk_tracker.rs +++ b/crates/librqbit/src/chunk_tracker.rs @@ -59,7 +59,7 @@ impl ChunkTracker { pub fn new(needed_pieces: BF, have_pieces: BF, lengths: Lengths) -> Self { // TODO: ideally this needs to be a list based on needed files, e.g. // last needed piece for each file. But let's keep simple for now. - let last_needed_piece_id = needed_pieces.iter_ones().rev().next(); + let last_needed_piece_id = needed_pieces.iter_ones().next_back(); // The last pieces first. Often important information is stored in the last piece. // E.g. if it's a video file, than the last piece often contains some index, or just