Skip to content

chore: upgrade rust toolchain to 1.89.0#5913

Merged
elmattic merged 3 commits intomainfrom
hm/rust-1.89
Aug 8, 2025
Merged

chore: upgrade rust toolchain to 1.89.0#5913
elmattic merged 3 commits intomainfrom
hm/rust-1.89

Conversation

@hanabi1224
Copy link
Copy Markdown
Contributor

@hanabi1224 hanabi1224 commented Aug 8, 2025

Summary of changes

Changes introduced in this pull request:

  • upgrade rust toolchain to 1.89.0
  • fix clippy warnings
warning: struct `VestingSchedule` is never constructed
  --> src/cli/subcommands/state_cmd.rs:18:8
   |
18 | struct VestingSchedule {
   |        ^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: field `0` is never read
  --> src/cli/subcommands/state_cmd.rs:19:14
   |
17 | #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
   |                           ----------------- field in this struct
18 | struct VestingSchedule {
19 |     entries: Vec<VestingScheduleEntry>,
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: consider removing this field

warning: method `setting_keys` is never used
  --> src/db/mod.rs:52:8
   |
39 | pub trait SettingsStore {
   |           ------------- method in this trait
...
52 |     fn setting_keys(&self) -> anyhow::Result<Vec<String>>;
   |        ^^^^^^^^^^^^

warning: method `exists` is never used
   --> src/db/mod.rs:116:8
    |
106 | pub trait EthMappingsStore {
    |           ---------------- method in this trait
...
116 |     fn exists(&self, key: &EthHash) -> anyhow::Result<bool>;
    |        ^^^^^^

warning: method `exists` is never used
   --> src/db/mod.rs:197:8
    |
192 | pub trait IndicesStore {
    |           ------------ method in this trait
...
197 |     fn exists(&self, key: &Cid) -> anyhow::Result<bool>;
    |        ^^^^^^

warning: method `len` is never used
  --> src/db/blockstore_with_read_cache.rs:18:8
   |
13 | pub trait BlockstoreReadCache {
   |           ------------------- method in this trait
...
18 |     fn len(&self) -> usize;
   |        ^^^

warning: struct `VoidBlockstoreReadCache` is never constructed
  --> src/db/blockstore_with_read_cache.rs:38:12
   |
38 | pub struct VoidBlockstoreReadCache;
   |            ^^^^^^^^^^^^^^^^^^^^^^^

warning: function `check_exhaustive` is never used
   --> src/shim/machine/manifest.rs:197:16
    |
197 |               fn check_exhaustive(it: $ty) {
    |                  ^^^^^^^^^^^^^^^^
...
209 | / exhaustive! {
210 | |     const ALL_BUILTINS: &[BuiltinActor] = &[
211 | |         BuiltinActor::System,
212 | |         BuiltinActor::Init,
...   |
227 | |     ];
228 | | }
    | |_- in this macro invocation
    |
    = note: this warning originates in the macro `exhaustive` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: this `if` statement can be collapsed
   --> src/blocks/tipset.rs:430:17
    |
430 | /                 if let Some(known_block_cid) = known_blocks.get(&tipset.epoch()) {
431 | |                     if known_block_cid == &tipset.min_ticket_block().cid().to_string() {
432 | |                         return store
433 | |                             .get_cbor(&genesis_cid)?
...   |
436 | |                 }
    | |_________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
    = note: `#[warn(clippy::collapsible_if)]` on by default
help: collapse nested if block
    |
430 ~                 if let Some(known_block_cid) = known_blocks.get(&tipset.epoch())
431 ~                     && known_block_cid == &tipset.min_ticket_block().cid().to_string() {
432 |                         return store
433 |                             .get_cbor(&genesis_cid)?
434 |                             .context("Genesis block missing from database");
435 ~                     }
    |

warning: this `if` statement can be collapsed
  --> src/chain/store/index.rs:50:9
   |
50 | /         if !is_env_truthy("FOREST_TIPSET_CACHE_DISABLED") {
51 | |             if let Some(ts) = self.ts_cache.lock().get(tsk) {
52 | |                 metrics::LRU_CACHE_HIT
53 | |                     .get_or_create(&metrics::values::TIPSET)
...  |
57 | |         }
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
50 ~         if !is_env_truthy("FOREST_TIPSET_CACHE_DISABLED")
51 ~             && let Some(ts) = self.ts_cache.lock().get(tsk) {
52 |                 metrics::LRU_CACHE_HIT
...
55 |                 return Ok(Some(ts.clone()));
56 ~             }
   |

warning: this `if` statement can be collapsed
  --> src/chain/store/tipset_tracker.rs:57:13
   |
57 | /             if let Ok(Some(block)) = CachingBlockHeader::load(&self.db, *cid) {
58 | |                 if header.miner_address == block.miner_address {
59 | |                     warn!(
60 | |                         "Have multiple blocks from miner {} at height {} in our tipset cache {}-{}",
...  |
67 | |             }
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
57 ~             if let Ok(Some(block)) = CachingBlockHeader::load(&self.db, *cid)
58 ~                 && header.miner_address == block.miner_address {
59 |                     warn!(
...
65 |                     );
66 ~                 }
   |

warning: this `if` statement can be collapsed
   --> src/chain_sync/network_context.rs:106:13
    |
106 | /             if let Ok(Ok(value)) = result {
107 | |                 if validate(&value) {
108 | |                     return Some(value);
109 | |                 }
110 | |             }
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
106 ~             if let Ok(Ok(value)) = result
107 ~                 && validate(&value) {
108 |                     return Some(value);
109 ~                 }
    |

warning: this `if` statement can be collapsed
   --> src/chain_sync/network_context.rs:312:17
    |
312 | /                 if let Ok(mean) = success_time_cost_millis_stats.lock().mean() {
313 | |                     if CHAIN_EXCHANGE_TIMEOUT_MILLIS.adapt_on_success(mean as _) {
314 | |                         tracing::debug!(
315 | |                             "Decreased chain exchange timeout to {}ms. Current average: {}ms",
...   |
320 | |                 }
    | |_________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
312 ~                 if let Ok(mean) = success_time_cost_millis_stats.lock().mean()
313 ~                     && CHAIN_EXCHANGE_TIMEOUT_MILLIS.adapt_on_success(mean as _) {
314 |                         tracing::debug!(
...
318 |                         );
319 ~                     }
    |

warning: this `if` statement can be collapsed
  --> src/chain_sync/validation.rs:77:13
   |
77 | /             if let Some(bad_block_cache) = bad_block_cache {
78 | |                 if bad_block_cache.peek(block.cid()).is_some() {
79 | |                     return Err(TipsetValidationError::InvalidBlock(*block.cid()));
80 | |                 }
81 | |             }
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
77 ~             if let Some(bad_block_cache) = bad_block_cache
78 ~                 && bad_block_cache.peek(block.cid()).is_some() {
79 |                     return Err(TipsetValidationError::InvalidBlock(*block.cid()));
80 ~                 }
   |

warning: this `if` statement can be collapsed
  --> src/cid_collections/mod.rs:78:13
   |
78 | /             if value.version() == cid::Version::V1 && value.codec() == fvm_ipld_encoding::DAG_CBOR {
79 | |                 if let Ok(small_hash) = value.hash().resize() {
80 | |                     let (code, digest, size) = small_hash.into_inner();
81 | |                     if code == u64::from(MultihashCode::Blake2b256) && size as usize == Self::WIDTH
...  |
86 | |             }
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
78 ~             if value.version() == cid::Version::V1 && value.codec() == fvm_ipld_encoding::DAG_CBOR
79 ~                 && let Ok(small_hash) = value.hash().resize() {
80 |                     let (code, digest, size) = small_hash.into_inner();
...
84 |                     }
85 ~                 }
   |

warning: this `if` statement can be collapsed
  --> src/cli/main.rs:30:13
   |
30 | /             if let Ok(name) = StateNetworkName::call(&client, ()).await {
31 | |                 if !matches!(NetworkChain::from_str(&name), Ok(NetworkChain::Mainnet)) {
32 | |                     CurrentNetwork::set_global(Network::Testnet);
33 | |                 }
34 | |             }
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
30 ~             if let Ok(name) = StateNetworkName::call(&client, ()).await
31 ~                 && !matches!(NetworkChain::from_str(&name), Ok(NetworkChain::Mainnet)) {
32 |                     CurrentNetwork::set_global(Network::Testnet);
33 ~                 }
   |

warning: this `if` statement can be collapsed
   --> src/cli/subcommands/net_cmd.rs:163:17
    |
163 | /                 if let Some(public_addrs) = nat_status.public_addrs {
164 | |                     if !public_addrs.is_empty() {
...   |
169 | |                 }
    | |_________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
163 ~                 if let Some(public_addrs) = nat_status.public_addrs
164 ~                     && !public_addrs.is_empty() {
165 |                         // Format is compatible with Go code:
166 |                         // `fmt.Println("Public address:", []string{"foo", "bar"})`
167 |                         println!("Public address: [{}]", public_addrs.join(" "));
168 ~                     }
    |

warning: this `if` statement can be collapsed
   --> src/daemon/context.rs:340:9
    |
340 | /         if let Some(dir) = path.parent() {
341 | |             if !dir.is_dir() {
342 | |                 std::fs::create_dir_all(dir).with_context(|| {
343 | |                     format!(
...   |
349 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
340 ~         if let Some(dir) = path.parent()
341 ~             && !dir.is_dir() {
342 |                 std::fs::create_dir_all(dir).with_context(|| {
...
347 |                 })?;
348 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/daemon/mod.rs:136:5
    |
136 | /     if !opts.skip_load.unwrap_or_default() {
137 | |         if let Some(path) = &config.client.snapshot_path {
138 | |             let (car_db_path, ts) = import_chain_as_forest_car(
139 | |                 path,
...   |
158 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
136 ~     if !opts.skip_load.unwrap_or_default()
137 ~         && let Some(path) = &config.client.snapshot_path {
138 |             let (car_db_path, ts) = import_chain_as_forest_car(
...
156 |             );
157 ~         }
    |

warning: this `if` statement can be collapsed
  --> src/db/car/any.rs:39:9
   |
39 | /         if let Ok(decompressed) = zstd::stream::decode_all(positioned_io::Cursor::new(&reader)) {
40 | |             if let Ok(mem_car) = super::PlainCar::new(decompressed) {
41 | |                 return Ok(AnyCar::Memory(mem_car));
42 | |             }
43 | |         }
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
39 ~         if let Ok(decompressed) = zstd::stream::decode_all(positioned_io::Cursor::new(&reader))
40 ~             && let Ok(mem_car) = super::PlainCar::new(decompressed) {
41 |                 return Ok(AnyCar::Memory(mem_car));
42 ~             }
   |

warning: this `if` statement can be collapsed
   --> src/db/car/plain.rs:378:5
    |
378 | /     if let Some(limit_position) = limit_position {
379 | |         if reader.stream_position()? >= limit_position {
380 | |             return Ok(None);
381 | |         }
382 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
378 ~     if let Some(limit_position) = limit_position
379 ~         && reader.stream_position()? >= limit_position {
380 |             return Ok(None);
381 ~         }
    |

warning: this `if` statement can be collapsed
   --> src/db/gc/snapshot.rs:172:13
    |
172 | /             if !self.running.load(Ordering::Relaxed)
173 | |                 && let Some(db) = &*self.db.read()
174 | |                 && let Some(car_db_head_epoch) = *self.car_db_head_epoch.read()
...   |
188 | |             }
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
174 ~                 && let Some(car_db_head_epoch) = *self.car_db_head_epoch.read()
175 ~                 && let Ok(head_key) = HeaviestTipsetKeyProvider::heaviest_tipset_key(db) {
176 |                     if let Ok(head) = Tipset::load_required(db, &head_key) {
...
185 |                     }
186 ~                 }
    |

warning: this `if` statement can be collapsed
   --> src/db/gc/snapshot.rs:176:17
    |
176 | /                 if let Ok(head_key) = HeaviestTipsetKeyProvider::heaviest_tipset_key(db) {
177 | |                     if let Ok(head) = Tipset::load_required(db, &head_key) {
178 | |                         let head_epoch = head.epoch();
179 | |                         if head_epoch - car_db_head_epoch >= snap_gc_interval_epochs
...   |
187 | |                 }
    | |_________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
176 ~                 if let Ok(head_key) = HeaviestTipsetKeyProvider::heaviest_tipset_key(db)
177 ~                     && let Ok(head) = Tipset::load_required(db, &head_key) {
178 |                         let head_epoch = head.epoch();
...
185 |                         }
186 ~                     }
    |

warning: this `if` statement can be collapsed
   --> src/db/gc/snapshot.rs:272:9
    |
272 | /         if let Some(blessed_lite_snapshot) = { self.blessed_lite_snapshot.read().clone() } {
273 | |             if blessed_lite_snapshot.is_file() {
274 | |                 let mut opts = ParityDb::to_options(self.db_root_dir.clone(), &self.db_config);
275 | |                 for col in [
...   |
361 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
272 ~         if let Some(blessed_lite_snapshot) = { self.blessed_lite_snapshot.read().clone() }
273 ~             && blessed_lite_snapshot.is_file() {
274 |                 let mut opts = ParityDb::to_options(self.db_root_dir.clone(), &self.db_config);
...
359 |                 }
360 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/key_management/wallet.rs:182:9
    |
182 | /         if let Some(addr_str) = i.strip_prefix("wallet-") {
183 | |             if let Ok(addr) = Address::from_str(addr_str) {
184 | |                 out.push(addr);
185 | |             }
186 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
182 ~         if let Some(addr_str) = i.strip_prefix("wallet-")
183 ~             && let Ok(addr) = Address::from_str(addr_str) {
184 |                 out.push(addr);
185 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/key_management/wallet.rs:205:5
    |
205 | /     if let Ok(default_keyinfo) = keystore.get("default") {
206 | |         if default_keyinfo == deleted_keyinfo {
207 | |             keystore
208 | |                 .remove("default")
...   |
211 | |     }
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
205 ~     if let Ok(default_keyinfo) = keystore.get("default")
206 ~         && default_keyinfo == deleted_keyinfo {
207 |             keystore
208 |                 .remove("default")
209 |                 .map_err(|_| Error::KeyNotExists)?;
210 ~         }
    |

warning: this `if` statement can be collapsed
  --> src/libp2p/chain_exchange/behaviour.rs:76:9
   |
76 | /         if let Some(tx) = self.response_channels.remove(request_id) {
77 | |             if let Err(err) = tx.send(Err(error.into())) {
...  |
84 | |         }
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
76 ~         if let Some(tx) = self.response_channels.remove(request_id)
77 ~             && let Err(err) = tx.send(Err(error.into())) {
78 |                 // Demoting log level here because the same request might be sent to multiple
...
82 |                 debug!("{err}");
83 ~             }
   |

warning: this `if` statement can be collapsed
   --> src/libp2p/hello/behaviour.rs:159:9
    |
159 | /         if let FromSwarm::ConnectionEstablished(e) = &event {
160 | |             if e.other_established == 0 {
161 | |                 self.pending_inbound_hello_peers
162 | |                     .insert(e.peer_id, Instant::now());
163 | |             }
164 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
159 ~         if let FromSwarm::ConnectionEstablished(e) = &event
160 ~             && e.other_established == 0 {
161 |                 self.pending_inbound_hello_peers
162 |                     .insert(e.peer_id, Instant::now());
163 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/libp2p/peer_manager.rs:258:17
    |
258 | /                 if let Some(expiration) = expiration {
259 | |                     if &now > expiration {
260 | |                         unban_list.push(*peer);
261 | |                     }
262 | |                 }
    | |_________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
258 ~                 if let Some(expiration) = expiration
259 ~                     && &now > expiration {
260 |                         unban_list.push(*peer);
261 ~                     }
    |

warning: this `if` statement can be collapsed
   --> src/libp2p/service.rs:238:21
    |
238 | /                     if let SwarmEvent::NewListenAddr {
239 | |                         address,
240 | |                         listener_id,
241 | |                     } = swarm.select_next_some().await
...   |
247 | |                     }
    | |_____________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
241 ~                     } = swarm.select_next_some().await
242 ~                         && id == listener_id {
243 |                             info!("p2p peer is now listening on: {address}");
244 |                             break;
245 ~                         }
    |

warning: this `if` statement can be collapsed
   --> src/libp2p_bitswap/request_manager.rs:152:13
    |
152 | /             if let Some(responder) = responder {
153 | |                 if let Err(e) = responder.send_async(success).await {
154 | |                     debug!("{e}");
155 | |                 }
156 | |             }
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
152 ~             if let Some(responder) = responder
153 ~                 && let Err(e) = responder.send_async(success).await {
154 |                     debug!("{e}");
155 ~                 }
    |

warning: this `if` statement can be collapsed
   --> src/libp2p_bitswap/request_manager.rs:224:9
    |
224 | /         if !success {
225 | |             if let Ok(data) = block_saved_rx.recv_deadline(deadline) {
226 | |                 success = true;
227 | |                 block_data = data;
228 | |             }
229 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
224 ~         if !success
225 ~             && let Ok(data) = block_saved_rx.recv_deadline(deadline) {
226 |                 success = true;
227 |                 block_data = data;
228 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/lotus_json/ipld.rs:229:9
    |
229 | /         if map.len() == 1 {
230 | |             if let Some(v) = map.get("/") {
231 | |                 match v {
232 | |                     Ipld::String(s) => {
...   |
261 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
229 ~         if map.len() == 1
230 ~             && let Some(v) = map.get("/") {
231 |                 match v {
...
259 |                 }
260 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/message_pool/msg_chain.rs:316:9
    |
316 | /         if let Some(prev) = prev {
317 | |             if eff_perf > 0.0 {
318 | |                 let prev_eff_perf = prev.0;
319 | |                 let prev_gas_limit = prev.1;
...   |
326 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
316 ~         if let Some(prev) = prev
317 ~             && eff_perf > 0.0 {
318 |                 let prev_eff_perf = prev.0;
...
324 |                 eff_perf = eff_perf_with_parent;
325 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/rpc/types/mod.rs:462:9
    |
462 | /         if let Some(from) = &self.from {
463 | |             if from != &msg.from {
464 | |                 return false;
465 | |             }
466 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
462 ~         if let Some(from) = &self.from
463 ~             && from != &msg.from {
464 |                 return false;
465 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/rpc/types/mod.rs:468:9
    |
468 | /         if let Some(to) = &self.to {
469 | |             if to != &msg.to {
470 | |                 return false;
471 | |             }
472 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
468 ~         if let Some(to) = &self.to
469 ~             && to != &msg.to {
470 |                 return false;
471 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/rpc/methods/chain.rs:103:29
    |
103 | / ...                   if !logs.is_empty() {
104 | | ...                       if let Err(e) = sender.send(logs) {
105 | | ...                           tracing::error!(
106 | | ...                               "Failed to send logs for tipset {}: {}",
...   |
112 | | ...                   }
    | |_______________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
103 ~                             if !logs.is_empty()
104 ~                                 && let Err(e) = sender.send(logs) {
105 |                                     tracing::error!(
...
110 |                                     break;
111 ~                                 }
    |

warning: this `if` statement can be collapsed
   --> src/rpc/methods/chain.rs:495:21
    |
495 | /                     if matches!(link_cid.codec(), fvm_ipld_encoding::DAG_CBOR) {
496 | |                         if let Ok(ipld) =
497 | |                             crate::utils::encoding::from_slice_with_fallback::<Ipld>(&data)
...   |
505 | |                     }
    | |_____________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
495 ~                     if matches!(link_cid.codec(), fvm_ipld_encoding::DAG_CBOR)
496 ~                         && let Ok(ipld) =
497 |                             crate::utils::encoding::from_slice_with_fallback::<Ipld>(&data)
...
503 |                             }
504 ~                         }
    |

warning: this `if` statement can be collapsed
   --> src/rpc/methods/eth/filter/mod.rs:163:13
    |
163 | /             if let Some(filter_store) = &self.filter_store {
164 | |                 if let Err(err) = filter_store.add(filter.clone()) {
165 | |                     ensure!(
166 | |                         event_filter_manager.remove(filter.id()).is_some(),
...   |
171 | |             }
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
163 ~             if let Some(filter_store) = &self.filter_store
164 ~                 && let Err(err) = filter_store.add(filter.clone()) {
165 |                     ensure!(
...
169 |                     bail!("Adding filter failed: {}", err);
170 ~                 }
    |

warning: this `if` statement can be collapsed
   --> src/rpc/methods/eth/filter/mod.rs:184:13
    |
184 | /             if let Some(filter_store) = &self.filter_store {
185 | |                 if let Err(err) = filter_store.add(filter.clone()) {
186 | |                     ensure!(manager.remove(filter.id()).is_some(), "Filter not found");
187 | |                     bail!("Adding filter failed: {}", err);
188 | |                 }
189 | |             }
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
184 ~             if let Some(filter_store) = &self.filter_store
185 ~                 && let Err(err) = filter_store.add(filter.clone()) {
186 |                     ensure!(manager.remove(filter.id()).is_some(), "Filter not found");
187 |                     bail!("Adding filter failed: {}", err);
188 ~                 }
    |

warning: this `if` statement can be collapsed
  --> src/rpc/methods/eth/trace.rs:48:5
   |
48 | /     if let Some(addr) = trace.state.delegated_address {
49 | |         if let Ok(eth_addr) = EthAddress::from_filecoin_address(&addr.into()) {
50 | |             return eth_addr;
51 | |         }
52 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
48 ~     if let Some(addr) = trace.state.delegated_address
49 ~         && let Ok(eth_addr) = EthAddress::from_filecoin_address(&addr.into()) {
50 |             return eth_addr;
51 ~         }
   |

warning: this `if` statement can be collapsed
   --> src/rpc/methods/eth/trace.rs:553:13
    |
553 | /             if trace.msg_rct.exit_code.is_success() {
554 | |                 if let Option::Some(actor_trace) = &trace.invoked_actor {
555 | |                     let to = trace_to_address(actor_trace);
556 | |                     env.last_byte_code = Some(to);
557 | |                 }
558 | |             }
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
553 ~             if trace.msg_rct.exit_code.is_success()
554 ~                 && let Option::Some(actor_trace) = &trace.invoked_actor {
555 |                     let to = trace_to_address(actor_trace);
556 |                     env.last_byte_code = Some(to);
557 ~                 }
    |

warning: this `if` statement can be collapsed
   --> src/rpc/methods/eth/types.rs:737:9
    |
737 | /         if let Some(from_addresses) = from_decoded_addresses {
738 | |             if !from_addresses.is_empty() && !from_addresses.contains(&trace_from) {
739 | |                 return Ok(false);
740 | |             }
741 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
737 ~         if let Some(from_addresses) = from_decoded_addresses
738 ~             && !from_addresses.is_empty() && !from_addresses.contains(&trace_from) {
739 |                 return Ok(false);
740 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/rpc/methods/eth/types.rs:744:9
    |
744 | /         if let Some(to_addresses) = to_decoded_addresses {
745 | |             if !to_addresses.is_empty() && !trace_to.is_some_and(|to| to_addresses.contains(&to)) {
746 | |                 return Ok(false);
747 | |             }
748 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
744 ~         if let Some(to_addresses) = to_decoded_addresses
745 ~             && !to_addresses.is_empty() && !trace_to.is_some_and(|to| to_addresses.contains(&to)) {
746 |                 return Ok(false);
747 ~             }
    |

warning: this `if` statement can be collapsed
  --> src/rpc/methods/eth/utils.rs:26:5
   |
26 | /     if let Ok(eth_addr) = EthAddress::from_filecoin_address(addr) {
27 | |         if !eth_addr.is_masked_id() {
28 | |             return Ok(Some(eth_addr));
29 | |         }
30 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
26 ~     if let Ok(eth_addr) = EthAddress::from_filecoin_address(addr)
27 ~         && !eth_addr.is_masked_id() {
28 |             return Ok(Some(eth_addr));
29 ~         }
   |

warning: this `if` statement can be collapsed
  --> src/rpc/methods/eth/utils.rs:42:13
   |
42 | /             if let Ok(eth_addr) = EthAddress::from_filecoin_address(&addr.into()) {
43 | |                 if !eth_addr.is_masked_id() {
44 | |                     // Conversable into an eth address, use it.
45 | |                     return Ok(Some(eth_addr));
46 | |                 }
47 | |             }
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
42 ~             if let Ok(eth_addr) = EthAddress::from_filecoin_address(&addr.into())
43 ~                 && !eth_addr.is_masked_id() {
44 |                     // Conversable into an eth address, use it.
45 |                     return Ok(Some(eth_addr));
46 ~                 }
   |

warning: this `if` statement can be collapsed
    --> src/rpc/methods/eth.rs:1146:9
     |
1146 | /         if msg.method_num() == EVMMethod::InvokeContract as MethodNum
1147 | |             || msg.method_num() == EAMMethod::CreateExternal as MethodNum
1148 | |         {
1149 | |             if let Ok(buffer) = decode_payload(msg.params(), codec) {
...    |
1158 | |         }
     | |_________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
     |
1146 ~         if (msg.method_num() == EVMMethod::InvokeContract as MethodNum
1147 ~             || msg.method_num() == EAMMethod::CreateExternal as MethodNum
1148 ~             || msg.method_num() == EAMMethod::CreateExternal as MethodNum)
1149 |         {
1150 ~             && let Ok(buffer) = decode_payload(msg.params(), codec) {
1151 |                 // If this is a valid "create external", unset the "to" address.
 ...
1157 |             // Yeah, we're going to ignore errors here because the user can send whatever they
1158 ~             // want and may send garbage.
     |

warning: this `if` statement can be collapsed
    --> src/rpc/methods/eth.rs:1510:5
     |
1510 | /     if let Some(limit) = limit {
1511 | |         if limit > LOOKBACK_NO_LIMIT
1512 | |             && ts.epoch() < ctx.chain_store().heaviest_tipset().epoch() - limit
...    |
1519 | |     }
     | |_____^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
     |
1510 ~     if let Some(limit) = limit
1511 ~         && limit > LOOKBACK_NO_LIMIT
1512 |             && ts.epoch() < ctx.chain_store().heaviest_tipset().epoch() - limit
 ...
1517 |             );
1518 ~         }
     |

warning: this `if` statement can be collapsed
    --> src/rpc/methods/eth.rs:2243:9
     |
2243 | /         if let BlockNumberOrHash::PredefinedBlock(ref predefined) = block_param {
2244 | |             if *predefined == Predefined::Pending {
2245 | |                 return Ok(EthUint64(ctx.mpool.get_sequence(&addr)?));
2246 | |             }
2247 | |         }
     | |_________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
     |
2243 ~         if let BlockNumberOrHash::PredefinedBlock(ref predefined) = block_param
2244 ~             && *predefined == Predefined::Pending {
2245 |                 return Ok(EthUint64(ctx.mpool.get_sequence(&addr)?));
2246 ~             }
     |

warning: this `if` statement can be collapsed
    --> src/rpc/methods/eth.rs:2510:9
     |
2510 | /         if let Ok(smsgs) = smsgs_result {
2511 | |             if let Some(smsg) = smsgs.first() {
2512 | |                 let hash = if smsg.is_delegated() {
2513 | |                     let chain_id = ctx.chain_config().eth_chain_id;
...    |
2523 | |         }
     | |_________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
     |
2510 ~         if let Ok(smsgs) = smsgs_result
2511 ~             && let Some(smsg) = smsgs.first() {
2512 |                 let hash = if smsg.is_delegated() {
 ...
2521 |                 return Ok(Some(hash));
2522 ~             }
     |

warning: this `if` statement can be collapsed
    --> src/rpc/methods/eth.rs:3500:17
     |
3500 | /                 if let Some(after) = filter.after.clone() {
3501 | |                     if trace_counter <= after.0 {
3502 | |                         continue;
3503 | |                     }
3504 | |                 }
     | |_________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
     |
3500 ~                 if let Some(after) = filter.after.clone()
3501 ~                     && trace_counter <= after.0 {
3502 |                         continue;
3503 ~                     }
     |

warning: this `if` statement can be collapsed
    --> src/rpc/methods/state.rs:1360:21
     |
1360 | /                     if task_set.len() == MAX_CONCURRENT_REQUESTS {
1361 | |                         if let Some(ret) = task_set.join_next().await {
1362 | |                             handle_worker(&mut fetched, &mut failures, ret?)
1363 | |                         }
1364 | |                     }
     | |_____________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
     |
1360 ~                     if task_set.len() == MAX_CONCURRENT_REQUESTS
1361 ~                         && let Some(ret) = task_set.join_next().await {
1362 |                             handle_worker(&mut fetched, &mut failures, ret?)
1363 ~                         }
     |

warning: this `if` statement can be collapsed
    --> src/rpc/methods/state.rs:2452:16
     |
2452 |           } else if let Some(from) = from_to.from {
     |  ________________^
2453 | |             if ctx.state_manager.lookup_id(&from, ts.as_ref())?.is_none() {
2454 | |                 return Ok(vec![]);
2455 | |             }
2456 | |         }
     | |_________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
     |
2452 ~         } else if let Some(from) = from_to.from
2453 ~             && ctx.state_manager.lookup_id(&from, ts.as_ref())?.is_none() {
2454 |                 return Ok(vec![]);
2455 ~             }
     |

warning: this `if` statement can be collapsed
   --> src/shim/executor.rs:183:9
    |
183 | /         if let Ok(amt) = Amtv0::load(receipts, db) {
184 | |             if let Ok(receipts) = amt.get(i) {
185 | |                 return Ok(receipts.cloned().map(Receipt::V4));
186 | |             }
187 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
183 ~         if let Ok(amt) = Amtv0::load(receipts, db)
184 ~             && let Ok(receipts) = amt.get(i) {
185 |                 return Ok(receipts.cloned().map(Receipt::V4));
186 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/shim/state_tree.rs:364:17
    |
364 | /                 if !matches!(self, Self::FvmV2(_) | Self::V0(_)) {
365 | |                     if let Some(address) = actor.delegated_address {
366 | |                         return Ok(address.into());
367 | |                     }
368 | |                 }
    | |_________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
364 ~                 if !matches!(self, Self::FvmV2(_) | Self::V0(_))
365 ~                     && let Some(address) = actor.delegated_address {
366 |                         return Ok(address.into());
367 ~                     }
    |

warning: this `if` statement can be collapsed
   --> src/state_manager/mod.rs:451:9
    |
451 | /         if let Ok(receipts) = Receipt::get_receipts(self.blockstore(), state_output.receipt_root) {
452 | |             if !receipts.is_empty() {
453 | |                 self.receipt_event_cache_handler
454 | |                     .insert_receipt(key, receipts);
455 | |             }
456 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
451 ~         if let Ok(receipts) = Receipt::get_receipts(self.blockstore(), state_output.receipt_root)
452 ~             && !receipts.is_empty() {
453 |                 self.receipt_event_cache_handler
454 |                     .insert_receipt(key, receipts);
455 ~             }
    |

warning: this `if` statement can be collapsed
   --> src/state_manager/mod.rs:751:9
    |
751 | /         if let Err(error_message) = result {
752 | |             if error_message.to_string() != REPLAY_HALT {
753 | |                 return Err(Error::Other(format!(
754 | |                     "unexpected error during execution : {error_message:}"
...   |
757 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
751 ~         if let Err(error_message) = result
752 ~             && error_message.to_string() != REPLAY_HALT {
753 |                 return Err(Error::Other(format!(
754 |                     "unexpected error during execution : {error_message:}"
755 |                 )));
756 ~             }
    |

warning: this `if` statement can be collapsed
    --> src/state_manager/mod.rs:1600:17
     |
1600 | /                 if let Ok(state) =
1601 | |                     StateTree::new_from_root(self.chain_store().db.clone(), ts.parent_state())
1602 | |                 {
1603 | |                     if let Ok(address) = state
...    |
1608 | |                 }
     | |_________________^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
     |
1601 ~                     StateTree::new_from_root(self.chain_store().db.clone(), ts.parent_state())
1602 ~                     && let Ok(address) = state
1603 |                         .resolve_to_deterministic_addr(self.chain_store().blockstore(), address)
1604 |                     {
1605 |                         return Ok(address);
1606 ~                     }
     |

warning: this `if` statement can be collapsed
  --> src/statediff/resolve.rs:49:13
   |
49 | /             if cid.codec() == DAG_CBOR {
50 | |                 if let Some(mut x) = bs.get_cbor(cid)? {
51 | |                     resolve_ipld(bs, &mut x, depth)?;
52 | |                     *ipld = x;
53 | |                 }
54 | |             }
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
49 ~             if cid.codec() == DAG_CBOR
50 ~                 && let Some(mut x) = bs.get_cbor(cid)? {
51 |                     resolve_ipld(bs, &mut x, depth)?;
52 |                     *ipld = x;
53 ~                 }
   |

warning: this `if` statement can be collapsed
  --> src/tool/subcommands/api_cmd/test_snapshot.rs:55:9
   |
55 | /         if let Some(mut guard) = db.eth_mappings_db.try_write() {
56 | |             if let Some(eth_mappings) = index.eth_mappings {
57 | |                 for (k, v) in eth_mappings.iter() {
58 | |                     guard.insert(EthHash::from_str(k)?, v.0.clone());
...  |
61 | |         }
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
55 ~         if let Some(mut guard) = db.eth_mappings_db.try_write()
56 ~             && let Some(eth_mappings) = index.eth_mappings {
57 |                 for (k, v) in eth_mappings.iter() {
58 |                     guard.insert(EthHash::from_str(k)?, v.0.clone());
59 |                 }
60 ~             }
   |

warning: this `if` statement can be collapsed
  --> src/tool/subcommands/api_cmd/test_snapshot.rs:62:9
   |
62 | /         if let Some(mut guard) = db.indices_db.try_write() {
63 | |             if let Some(indices) = index.indices {
64 | |                 for (k, v) in indices.iter() {
65 | |                     guard.insert(Cid::from_str(k)?, v.0.clone());
...  |
68 | |         }
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
62 ~         if let Some(mut guard) = db.indices_db.try_write()
63 ~             && let Some(indices) = index.indices {
64 |                 for (k, v) in indices.iter() {
65 |                     guard.insert(Cid::from_str(k)?, v.0.clone());
66 |                 }
67 ~             }
   |

warning: this `if` statement can be collapsed
  --> src/utils/io/writer_checksum.rs:35:9
   |
35 | /         if let Some(hasher) = &mut this.hasher {
36 | |             if let Poll::Ready(Ok(size)) = w {
37 | |                 if size > 0 {
38 | |                     #[allow(clippy::indexing_slicing)]
...  |
42 | |         }
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
35 ~         if let Some(hasher) = &mut this.hasher
36 ~             && let Poll::Ready(Ok(size)) = w {
37 |                 if size > 0 {
...
40 |                 }
41 ~             }
   |

warning: this `if` statement can be collapsed
  --> src/utils/io/writer_checksum.rs:36:13
   |
36 | /             if let Poll::Ready(Ok(size)) = w {
37 | |                 if size > 0 {
38 | |                     #[allow(clippy::indexing_slicing)]
39 | |                     hasher.update(&buf[..size]);
40 | |                 }
41 | |             }
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
36 ~             if let Poll::Ready(Ok(size)) = w
37 ~                 && size > 0 {
38 |                     #[allow(clippy::indexing_slicing)]
39 |                     hasher.update(&buf[..size]);
40 ~                 }
   |

warning: this `if` statement can be collapsed
  --> src/utils/misc/adaptive_value_provider.rs:37:9
   |
37 | /         if let Some(record) = record {
38 | |             if record < new_value {
39 | |                 return false;
40 | |             }
41 | |         }
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
37 ~         if let Some(record) = record
38 ~             && record < new_value {
39 |                 return false;
40 ~             }
   |

warning: this `if` statement can be collapsed
  --> src/utils/misc/adaptive_value_provider.rs:52:9
   |
52 | /         if let Some(record) = record {
53 | |             if record > new_value {
54 | |                 return false;
55 | |             }
56 | |         }
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
52 ~         if let Some(record) = record
53 ~             && record > new_value {
54 |                 return false;
55 ~             }
   |

warning: this `if` statement can be collapsed
  --> src/utils/net/download_file.rs:37:5
   |
37 | /     if let Some(cache_file_dir) = cache_file_path.parent() {
38 | |         if !cache_file_dir.is_dir() {
39 | |             std::fs::create_dir_all(cache_file_dir)?;
40 | |         }
41 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
   |
37 ~     if let Some(cache_file_dir) = cache_file_path.parent()
38 ~         && !cache_file_dir.is_dir() {
39 |             std::fs::create_dir_all(cache_file_dir)?;
40 ~         }
   |

warning: hiding a lifetime that's elided elsewhere is confusing
   --> src/cid_collections/hash_map.rs:112:18
    |
112 |     pub fn entry(&mut self, key: Cid) -> Entry<V> {
    |                  ^^^^^^^^^               -------- the same lifetime is hidden here
    |                  |
    |                  the lifetime is elided here
    |
    = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
    = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: use `'_` for type paths
    |
112 |     pub fn entry(&mut self, key: Cid) -> Entry<'_, V> {
    |                                                +++

warning: hiding a lifetime that's elided elsewhere is confusing
   --> src/cli_shared/snapshot.rs:270:20
    |
270 |     fn full(input: &str) -> nom::IResult<&str, ParsedFilename> {
    |                    ^^^^                  ----  -------------- the same lifetime is hidden here
    |                    |                     |
    |                    |                     the same lifetime is elided here
    |                    the lifetime is elided here
    |
    = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
help: use `'_` for type paths
    |
270 |     fn full(input: &str) -> nom::IResult<&str, ParsedFilename<'_>> {
    |                                                              ++++

warning: hiding a lifetime that's elided elsewhere is confusing
   --> src/cli_shared/snapshot.rs:294:21
    |
294 |     fn short(input: &str) -> nom::IResult<&str, ParsedFilename> {
    |                     ^^^^                  ----  -------------- the same lifetime is hidden here
    |                     |                     |
    |                     |                     the same lifetime is elided here
    |                     the lifetime is elided here
    |
    = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
help: use `'_` for type paths
    |
294 |     fn short(input: &str) -> nom::IResult<&str, ParsedFilename<'_>> {
    |                                                               ++++

warning: `forest-filecoin` (lib) generated 69 warnings (run `cargo clippy --fix --lib -p forest-filecoin` to apply 58 suggestions)
warning: this `if` statement can be collapsed
  --> tests/lints/mod.rs:84:9
   |
84 | /         if i.attrs
85 | |             .iter()
86 | |             .any(|attr| attr == &parse_quote!(#[test]) || attr == &parse_quote!(#[tokio::test]))
...  |
95 | |         }
   | |_________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
   = note: `#[warn(clippy::collapsible_if)]` on by default
help: collapse nested if block
   |
86 ~             .any(|attr| attr == &parse_quote!(#[test]) || attr == &parse_quote!(#[tokio::test]))
87 ~             && let ReturnType::Type(..) = i.sig.output {
88 |                 self.violations.push(
...
92 |                 )
93 ~             }
   |

warning: this `if` statement can be collapsed
   --> tests/lints/mod.rs:134:9
    |
134 | /         if i.path.is_ident("assert") {
135 | |             if let Ok(exprs) = i.parse_body_with(Punctuated::<Expr, Token![,]>::parse_terminated) {
136 | |                 if let Some(Expr::Binary(binary)) = exprs.first() {
137 | |                     match binary.op {
...   |
152 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
134 ~         if i.path.is_ident("assert")
135 ~             && let Ok(exprs) = i.parse_body_with(Punctuated::<Expr, Token![,]>::parse_terminated) {
136 |                 if let Some(Expr::Binary(binary)) = exprs.first() {
...
150 |                 }
151 ~             }
    |

warning: this `if` statement can be collapsed
   --> tests/lints/mod.rs:135:13
    |
135 | /             if let Ok(exprs) = i.parse_body_with(Punctuated::<Expr, Token![,]>::parse_terminated) {
136 | |                 if let Some(Expr::Binary(binary)) = exprs.first() {
137 | |                     match binary.op {
138 | |                         BinOp::Eq(_) => self.violations.push(
...   |
151 | |             }
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
135 ~             if let Ok(exprs) = i.parse_body_with(Punctuated::<Expr, Token![,]>::parse_terminated)
136 ~                 && let Some(Expr::Binary(binary)) = exprs.first() {
137 |                     match binary.op {
...
149 |                     }
150 ~                 }
    |

warning: `forest-filecoin` (test "lint") generated 3 warnings (run `cargo clippy --fix --test "lint"` to apply 3 suggestions)
warning: called `unwrap_err` on `result` after checking its variant with `is_err`
   --> src/rpc/registry/actors_reg.rs:248:37
    |
247 |                 if result.is_err() {
    |                 ------------------ help: try: `if let Err(<item>) = result`
248 |                     let error_msg = result.unwrap_err().to_string();
    |                                     ^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
    = note: `#[warn(clippy::unnecessary_unwrap)]` on by default

warning: called `unwrap_err` on `result` after checking its variant with `is_err`
   --> src/rpc/registry/methods_reg.rs:268:33
    |
267 |             if result.is_err() {
    |             ------------------ help: try: `if let Err(<item>) = result`
268 |                 let error_msg = result.unwrap_err().to_string();
    |                                 ^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap

warning: `forest-filecoin` (lib test) generated 69 warnings (67 duplicates)
    Finished `dev` profile [unoptimized] target(s) in 49.92s

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Summary by CodeRabbit

  • Refactor

    • Enhanced code readability by consolidating nested conditional statements into single-line expressions across the application without changing user-facing behavior.
    • Clarified internal method signatures with explicit lifetime annotations and removed unused methods.
    • Suppressed compiler warnings for certain unused internal methods.
  • Chores

    • Updated the Rust toolchain version to 1.89.0.
  • Removals

    • Removed unused internal data structures and methods without affecting end-user functionality.
  • Bug Fixes

    • No user-facing bugs were addressed; all changes are structural or stylistic.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 8, 2025

Walkthrough

This change set refactors numerous conditional statements throughout the codebase, replacing nested if and if let constructs with Rust's more concise combined pattern matching and logical AND (&&) syntax. Additionally, some function and struct signatures are updated to clarify lifetimes, and a few unused struct definitions and trait methods are removed. Minor test and attribute adjustments are also present.

Changes

Cohort / File(s) Change Summary
Rust Toolchain Update
rust-toolchain.toml
Rust toolchain version updated from 1.88.0 to 1.89.0.
Conditional Refactoring (General)
src/blocks/tipset.rs, src/chain/store/index.rs, src/chain/store/tipset_tracker.rs, src/chain_sync/network_context.rs, src/chain_sync/validation.rs, src/cid_collections/mod.rs, src/cli/main.rs, src/cli/subcommands/net_cmd.rs, src/daemon/context.rs, src/daemon/mod.rs, src/db/car/any.rs, src/db/car/plain.rs, src/db/gc/snapshot.rs, src/key_management/wallet.rs, src/libp2p/chain_exchange/behaviour.rs, src/libp2p/hello/behaviour.rs, src/libp2p/peer_manager.rs, src/libp2p/service.rs, src/libp2p_bitswap/request_manager.rs, src/lotus_json/ipld.rs, src/message_pool/msg_chain.rs, src/rpc/methods/chain.rs, src/rpc/methods/eth.rs, src/rpc/methods/eth/filter/mod.rs, src/rpc/methods/eth/trace.rs, src/rpc/methods/eth/types.rs, src/rpc/methods/eth/utils.rs, src/rpc/methods/state.rs, src/rpc/registry/actors_reg.rs, src/rpc/registry/methods_reg.rs, src/rpc/types/mod.rs, src/shim/executor.rs, src/shim/state_tree.rs, src/state_manager/mod.rs, src/statediff/resolve.rs, src/tool/subcommands/api_cmd/test_snapshot.rs, src/utils/io/writer_checksum.rs, src/utils/misc/adaptive_value_provider.rs, src/utils/net/download_file.rs, tests/lints/mod.rs
Nested if and if let statements refactored into single-line combined conditions using Rust's if let ... && ... syntax for conciseness and clarity. No changes to logic or control flow.
Lifetime and Signature Adjustments
src/cid_collections/hash_map.rs, src/cli_shared/snapshot.rs
Function/method return types updated to include explicit lifetimes, clarifying borrow semantics.
Public API Removals and Attribute Adjustments
src/cli/subcommands/state_cmd.rs, src/db/blockstore_with_read_cache.rs, src/db/mod.rs, src/shim/machine/manifest.rs
Removal of unused structs and trait methods; addition of #[allow(dead_code)] to suppress warnings for potentially unused methods.
Test Refactoring
src/rpc/registry/actors_reg.rs, src/rpc/registry/methods_reg.rs
Test error handling refactored for idiomatic pattern matching.

Sequence Diagram(s)

Not applicable: changes are widespread refactorings of conditional logic and do not introduce or alter high-level control flow or feature interactions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

rust

Suggested reviewers

  • elmattic
  • LesnyRumcajs
  • akaladarshi

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bac0969 and 5147c74.

📒 Files selected for processing (2)
  • src/db/blockstore_with_read_cache.rs (0 hunks)
  • src/rpc/registry/methods_reg.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • src/db/blockstore_with_read_cache.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/rpc/registry/methods_reg.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: All lint checks
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: Build Ubuntu
  • GitHub Check: Build MacOS
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: tests
  • GitHub Check: tests-release
  • GitHub Check: Analyze (rust)
  • GitHub Check: Analyze (go)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hm/rust-1.89

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hanabi1224 hanabi1224 marked this pull request as ready for review August 8, 2025 03:21
@hanabi1224 hanabi1224 requested a review from a team as a code owner August 8, 2025 03:21
@hanabi1224 hanabi1224 requested review from akaladarshi and elmattic and removed request for a team August 8, 2025 03:21
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
src/rpc/methods/eth.rs (4)

1146-1155: Minor readability – consider extracting the predicate instead of chaining let-conditions

The new let-chain is fully correct, but the three-part condition mixes
  • two numeric comparisons
  • a pattern binding (let Ok(buffer) = …)

into one boolean expression.
A small helper boolean or a matches!() would keep the intent explicit and
avoid the long parenthesised condition.

let is_evm_invocation =
    matches!(msg.method_num(),
        m if m == EVMMethod::InvokeContract as MethodNum
          || m == EAMMethod::CreateExternal as MethodNum);

if is_evm_invocation {
    if let Ok(buffer) = decode_payload(msg.params(), codec) {}
}

Purely cosmetic, but easier to scan when skimming large blocks.


1509-1516: Micro-optimisation – avoid recomputing heaviest_tipset() inside the if let chain

ctx.chain_store().heaviest_tipset() performs disk/network IO.
Calling it once and re-using the epoch avoids the extra lookup every time this
branch is evaluated:

let head_epoch = ctx.chain_store().heaviest_tipset().epoch();
if let Some(limit) = limit
    && limit > LOOKBACK_NO_LIMIT
    && ts.epoch() < head_epoch - limit
{
    bail!("tipset {} is older than the allowed lookback limit",
          ts.key().format_lotus());
}

Not critical, but worth it in hot paths.


2241-2244: Let-chain is correct; using matches! may read a bit clearer

The new pattern works, but:

if matches!(block_param, BlockNumberOrHash::PredefinedBlock(Predefined::Pending)) {
    return Ok(EthUint64(ctx.mpool.get_sequence(&addr)?));
}

avoids borrowing quirks and reads closer to “if the param is Pending…”.
Feel free to ignore – stylistic only.


3498-3503: Very small nit – clone avoided on every iteration

filter.after.clone() allocates on every matching trace. Caching once outside
the loop is cheaper:

let after = filter.after;if let Some(after) = after && trace_counter <= after.0 {
    continue;
}

Negligible in practice, but free and reads the same.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 163eeb4 and bac0969.

📒 Files selected for processing (47)
  • rust-toolchain.toml (1 hunks)
  • src/blocks/tipset.rs (1 hunks)
  • src/chain/store/index.rs (1 hunks)
  • src/chain/store/tipset_tracker.rs (1 hunks)
  • src/chain_sync/network_context.rs (2 hunks)
  • src/chain_sync/validation.rs (1 hunks)
  • src/cid_collections/hash_map.rs (1 hunks)
  • src/cid_collections/mod.rs (1 hunks)
  • src/cli/main.rs (1 hunks)
  • src/cli/subcommands/net_cmd.rs (1 hunks)
  • src/cli/subcommands/state_cmd.rs (0 hunks)
  • src/cli_shared/snapshot.rs (2 hunks)
  • src/daemon/context.rs (1 hunks)
  • src/daemon/mod.rs (1 hunks)
  • src/db/blockstore_with_read_cache.rs (1 hunks)
  • src/db/car/any.rs (1 hunks)
  • src/db/car/plain.rs (1 hunks)
  • src/db/gc/snapshot.rs (2 hunks)
  • src/db/mod.rs (3 hunks)
  • src/key_management/wallet.rs (2 hunks)
  • src/libp2p/chain_exchange/behaviour.rs (1 hunks)
  • src/libp2p/hello/behaviour.rs (1 hunks)
  • src/libp2p/peer_manager.rs (1 hunks)
  • src/libp2p/service.rs (1 hunks)
  • src/libp2p_bitswap/request_manager.rs (2 hunks)
  • src/lotus_json/ipld.rs (1 hunks)
  • src/message_pool/msg_chain.rs (1 hunks)
  • src/rpc/methods/chain.rs (2 hunks)
  • src/rpc/methods/eth.rs (5 hunks)
  • src/rpc/methods/eth/filter/mod.rs (2 hunks)
  • src/rpc/methods/eth/trace.rs (2 hunks)
  • src/rpc/methods/eth/types.rs (1 hunks)
  • src/rpc/methods/eth/utils.rs (2 hunks)
  • src/rpc/methods/state.rs (2 hunks)
  • src/rpc/registry/actors_reg.rs (1 hunks)
  • src/rpc/registry/methods_reg.rs (1 hunks)
  • src/rpc/types/mod.rs (1 hunks)
  • src/shim/executor.rs (1 hunks)
  • src/shim/machine/manifest.rs (1 hunks)
  • src/shim/state_tree.rs (1 hunks)
  • src/state_manager/mod.rs (3 hunks)
  • src/statediff/resolve.rs (1 hunks)
  • src/tool/subcommands/api_cmd/test_snapshot.rs (1 hunks)
  • src/utils/io/writer_checksum.rs (1 hunks)
  • src/utils/misc/adaptive_value_provider.rs (2 hunks)
  • src/utils/net/download_file.rs (1 hunks)
  • tests/lints/mod.rs (2 hunks)
💤 Files with no reviewable changes (1)
  • src/cli/subcommands/state_cmd.rs
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: hanabi1224
PR: ChainSafe/forest#5886
File: interop-tests/src/tests/go_app/gen.go:29-29
Timestamp: 2025-08-07T13:39:15.080Z
Learning: Auto-generated files like those created by rust2go (indicated by "Generated by rust2go. Please DO NOT edit this C part manually." comment) in the Forest project should be skipped during code review as they are not intended for manual editing.
📚 Learning: 2025-08-07T13:39:36.941Z
Learnt from: hanabi1224
PR: ChainSafe/forest#5886
File: interop-tests/src/tests/go_app/gen.go:88-90
Timestamp: 2025-08-07T13:39:36.941Z
Learning: Skip reviewing auto-generated files marked with "Generated by rust2go. Please DO NOT edit this C part manually." as these should not be manually edited and any issues should be addressed in the code generation tool or source templates instead.

Applied to files:

  • src/shim/machine/manifest.rs
📚 Learning: 2025-08-06T14:36:08.654Z
Learnt from: hanabi1224
PR: ChainSafe/forest#5886
File: src/daemon/db_util.rs:244-259
Timestamp: 2025-08-06T14:36:08.654Z
Learning: The `import_f3_snapshot` function already prints success messages internally, so additional success logging at the call site is not needed.

Applied to files:

  • src/daemon/mod.rs
📚 Learning: 2025-08-04T13:36:22.993Z
Learnt from: hanabi1224
PR: ChainSafe/forest#5835
File: src/chain/tests.rs:58-76
Timestamp: 2025-08-04T13:36:22.993Z
Learning: In the Forest codebase, `Vec<u8>` can be used as an `AsyncWrite` implementation in test contexts. The user confirmed that tests using `&mut Vec<u8>` with `export` and `export_v2` functions compile and pass both locally and on CI.

Applied to files:

  • src/utils/io/writer_checksum.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: tests-release
  • GitHub Check: tests
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: Build MacOS
  • GitHub Check: Build Ubuntu
  • GitHub Check: All lint checks
  • GitHub Check: Analyze (rust)
  • GitHub Check: Analyze (go)
🔇 Additional comments (65)
rust-toolchain.toml (1)

2-3: Confirm downstream consumers & CI images are aligned with the 1.89.0 bump

Bumping the channel here is fine, but please double-check that:

  1. All CI jobs (Docker images, GitHub Actions rust-toolchain steps, etc.) pull 1.89.0.
  2. Cargo.toml workspaces that declare rust-version are updated if you want MSRV == 1.89.
  3. External documentation (README / CONTRIBUTING) that cites the required Rust version is revised.

This avoids version drift between local dev and CI.

src/shim/machine/manifest.rs (1)

197-197: LGTM: Appropriate use of dead code attribute

The #[allow(dead_code)] attribute is correctly applied to the check_exhaustive function within the macro. This function serves as a compile-time exhaustiveness check for enum variants, and the compiler may not recognize its usage within the macro context, leading to false dead code warnings.

src/libp2p/peer_manager.rs (1)

258-262: LGTM: Clean conditional refactoring

The nested conditional statements have been successfully refactored into a single if let ... && expression. This change improves readability while maintaining identical logic - only unbanning peers when an expiration time exists and the current time has passed that expiration.

src/cli/main.rs (1)

30-34: LGTM: Effective conditional consolidation

The refactoring successfully combines the network name retrieval check with the network type validation into a single conditional expression. The logic remains intact: only setting the global network to Testnet when the API call succeeds and the network is not Mainnet.

src/libp2p/hello/behaviour.rs (1)

159-164: LGTM: Streamlined connection event handling

The conditional refactoring properly combines the pattern matching and condition check into a single expression. This maintains the same behavior of tracking new peer connections (when other_established == 0) while improving code readability and reducing nesting depth.

src/statediff/resolve.rs (1)

49-54: LGTM: Improved IPLD resolution logic

The conditional refactoring successfully combines the codec validation and optional value extraction into a single expression using let-chains. This maintains the same behavior of only resolving DAG_CBOR links that exist in the blockstore, while reducing nesting and improving code clarity. The error handling is correctly preserved.

src/db/car/any.rs (1)

39-43: LGTM! Clean refactoring using && let pattern.

The nested if let statements have been correctly refactored into a single combined conditional using the && let pattern. This maintains the same short-circuiting behavior while improving readability.

src/libp2p/chain_exchange/behaviour.rs (1)

76-84: LGTM! Correct consolidation of nested conditionals.

The refactoring correctly combines the response channel removal and error sending into a single if let && let expression. The error handling logic is preserved unchanged.

src/shim/state_tree.rs (1)

364-368: LGTM! Improved pattern matching with direct value extraction.

The refactoring correctly combines the state tree version check with delegated address extraction. This eliminates the need for separate unwrapping and improves code clarity.

src/daemon/context.rs (1)

340-349: LGTM! Proper consolidation of directory existence and type checks.

The refactoring correctly combines the parent directory extraction with the directory type validation using && !dir.is_dir(). The directory creation logic and error handling remain unchanged.

src/utils/net/download_file.rs (1)

37-41: LGTM! Clean refactoring of nested conditionals.

The change correctly combines the nested if let and if statements into a single compound condition using Rust's pattern matching with logical AND. This improves code readability while maintaining identical functionality.

src/message_pool/msg_chain.rs (1)

316-326: LGTM! Improved conditional structure.

The refactoring correctly combines the nested if let and if statements into a single compound condition. The logic for calculating effective performance with parent remains unchanged while improving code clarity.

src/rpc/types/mod.rs (1)

462-472: LGTM! Consistent refactoring of filter logic.

Both conditional blocks correctly combine nested if let and comparison checks into compound conditions. The early return logic for message filtering is preserved while improving code readability and consistency.

src/libp2p_bitswap/request_manager.rs (2)

152-156: LGTM! Cleaner async error handling.

The refactoring correctly combines the optional responder check with the async send error handling into a single compound condition. The error logging behavior is preserved while improving code clarity.


224-227: LGTM! Improved deadline handling logic.

The change correctly combines the success check with block data reception into a single compound condition. This maintains the same timeout behavior while making the control flow more readable.

src/utils/misc/adaptive_value_provider.rs (2)

37-41: LGTM! Simplified record validation logic.

The refactoring correctly combines the record existence check with the value comparison into a single compound condition. This improves readability while maintaining the same validation logic for the increase operation.


52-56: LGTM! Consistent pattern with decrease logic.

Similar to the increase method, this change correctly combines record validation with value comparison. The early return behavior for boundary conditions is preserved while improving code clarity.

src/db/mod.rs (3)

52-53: LGTM - Appropriate dead code suppression

The #[allow(dead_code)] attribute is correctly applied to a trait method that's part of the public API but may not be actively used, maintaining clean compilation without removing necessary interface methods.


117-118: LGTM - Appropriate dead code suppression

The #[allow(dead_code)] attribute is correctly applied to maintain the trait interface completeness while suppressing compiler warnings for unused methods.


199-200: LGTM - Appropriate dead code suppression

Consistent application of #[allow(dead_code)] attribute for trait methods that are part of the public interface but may not be actively used in the current codebase.

src/cid_collections/hash_map.rs (1)

112-112: LGTM - Explicit lifetime parameter improves correctness

The change from Entry<V> to Entry<'_, V> correctly makes the lifetime explicit, matching the Entry<'a, V: 'a> enum definition and clarifying the lifetime relationship between the returned entry and the mutable borrow of self.

src/libp2p/service.rs (1)

242-246: LGTM - Effective use of let-chaining

The refactoring correctly combines the event pattern matching with the equality check using Rust's let-chaining syntax (if let ... && condition), making the code more concise while maintaining the same logic and control flow.

src/utils/io/writer_checksum.rs (1)

35-41: LGTM - Clean refactoring with let-chaining

The refactoring effectively combines the hasher availability check, write operation status check, and size validation into a single if let statement using let-chaining. The logic remains identical while improving code readability and conciseness.

src/key_management/wallet.rs (2)

182-186: LGTM - Effective let-chaining in address filtering

The refactoring correctly combines the prefix stripping and address parsing operations using let-chaining, ensuring only valid wallet addresses are included in the output while maintaining the same filtering logic.


205-211: LGTM - Clean conditional logic for default key cleanup

The let-chaining refactoring correctly combines the default keyinfo retrieval and equality check, ensuring the default key is only removed when it matches the deleted key. The logic remains identical while improving code conciseness.

src/cli_shared/snapshot.rs (2)

270-270: LGTM! Improved lifetime explicitness.

The explicit lifetime parameter '_ in the return type correctly reflects that ParsedFilename borrows from the input string slice. This change improves type safety and aligns with Rust's lifetime elision guidelines.


294-294: LGTM! Consistent lifetime annotation.

This change matches the full function's lifetime annotation, maintaining consistency across the parsing functions while correctly expressing the borrowing relationship.

src/db/car/plain.rs (1)

378-382: LGTM! Improved conditional pattern.

The refactoring from nested if let and if statements to a combined if let ... && pattern is more idiomatic Rust. The logic remains identical while improving readability and conciseness.

tests/lints/mod.rs (2)

84-94: LGTM! Cleaner conditional logic.

The refactoring combines the test attribute check with the return type pattern matching into a single, more readable condition. This follows the same modernization pattern used throughout the PR.


133-149: LGTM! Well-structured conditional consolidation.

The refactoring effectively combines three separate checks (macro path, parse body, and expression type) into a single, readable condition using multiple let-pattern conditions with &&. This significantly improves code clarity while preserving the exact same logic.

src/rpc/methods/state.rs (2)

360-364: LGTM! Modern Rust syntax improvement

The refactor from nested if statements to the combined if with && let Some(ret) = task_set.join_next().await pattern is a good use of modern Rust syntax. This makes the code more concise while preserving the exact same logic flow.


452-456: LGTM! Cleaner pattern matching

The refactor from nested if statements to the combined if let Some(from) = from_to.from && ... pattern improves code readability. The logic remains identical - early return with an empty vector when the from address is specified but has no lookup ID.

src/lotus_json/ipld.rs (1)

229-261: LGTM! Clean refactoring of nested conditionals.

This change successfully combines nested if statements into a more idiomatic Rust pattern using if let ... &&. The logic remains identical while improving readability and following Clippy suggestions.

src/state_manager/mod.rs (3)

451-456: LGTM! Clean conditional refactoring.

This change combines the nested if let Ok(receipts) and if !receipts.is_empty() checks into a single, more readable condition. The logic remains identical while following Rust idioms.


751-757: LGTM! Improved error handling pattern.

The refactoring combines the error check with the string comparison in a single if let condition, making the error handling more concise while preserving the exact same logic.


600-606: LGTM! Excellent use of chained let patterns.

This change elegantly combines two nested if let Ok(...) conditions using Rust's let-chaining with &&, making the early return logic much cleaner and more idiomatic.

src/rpc/registry/methods_reg.rs (1)

267-273: LGTM! More idiomatic error handling.

This change replaces the explicit is_err() check followed by unwrap_err() with the more idiomatic if let Err(e) = result pattern. This directly binds the error for use while being safer and more readable.

src/cli/subcommands/net_cmd.rs (1)

163-169: LGTM! Clean refactoring of nested conditionals.

The refactoring from nested if let and if statements to a combined if let ... && pattern maintains identical logic while improving readability. This follows modern Rust idioms and is consistent with the Clippy suggestions.

src/chain/store/tipset_tracker.rs (1)

57-67: LGTM! Effective consolidation of conditional logic.

The refactoring successfully combines the nested conditionals into a single if let ... && pattern. The logic remains identical - it only issues a warning when both the block header loads successfully and the miner addresses match, which is the intended behavior for detecting multiple blocks from the same miner.

src/chain_sync/validation.rs (1)

77-81: LGTM! Improved conditional structure in validation logic.

The refactoring elegantly combines the nested conditionals into a single expression. The behavior is preserved exactly - it only returns an InvalidBlock error when both the bad_block_cache exists and contains the block's CID. This aligns with the systematic Clippy fixes throughout the codebase.

src/rpc/registry/actors_reg.rs (1)

247-255: LGTM! More idiomatic error handling pattern.

The refactoring from result.is_err() + result.unwrap_err() to if let Err(e) = result is more idiomatic Rust. This pattern directly binds the error value and eliminates the potential for panic while being more concise and readable.

src/shim/executor.rs (1)

183-187: LGTM! Clean consolidation using let-chains.

The refactoring effectively combines two nested if let statements into a single condition using the let-chains feature (&& let Ok(...)). This maintains identical logic while improving readability - it only returns the V4 receipt when both the AMT loads successfully and getting the receipt at index i succeeds.

src/chain/store/index.rs (1)

50-57: LGTM: Clean refactoring to modern Rust syntax

The refactoring correctly combines nested conditionals into a single if let ... && expression. This maintains the exact same logic while using more idiomatic Rust syntax introduced in recent versions.

src/rpc/methods/eth/types.rs (1)

737-750: LGTM: Consistent pattern matching refactoring

Both refactorings correctly consolidate nested conditionals into single if let ... && expressions. The logic for filtering addresses remains unchanged, and the new syntax is more concise and idiomatic.

src/tool/subcommands/api_cmd/test_snapshot.rs (1)

55-68: LGTM: Proper refactoring of nested lock acquisition

Both refactorings correctly combine the lock acquisition check with data existence check. The short-circuiting behavior is preserved - if try_write() returns None, the second condition won't be evaluated, maintaining the original safety guarantees.

src/rpc/methods/eth/trace.rs (2)

48-52: LGTM: Clean conditional chaining for address conversion

The refactoring correctly combines the option check with the result check into a single conditional. Both conditions must succeed for the early return, maintaining the original logic.


553-558: LGTM: Proper consolidation of success and actor checks

The refactoring correctly combines the exit code success check with the actor trace existence check. The use of Option::Some is valid syntax and functionally equivalent to Some.

src/chain_sync/network_context.rs (2)

106-110: LGTM: Efficient validation chaining

The refactoring correctly combines the nested Ok result check with the validation function call. This maintains the same short-circuiting behavior while being more concise.


312-320: LGTM: Proper timeout adaptation logic consolidation

The refactoring correctly combines the mean calculation success check with the timeout adaptation result. The logging only occurs when both conditions are met, preserving the original behavior.

src/rpc/methods/eth/filter/mod.rs (2)

163-165: LGTM! Clean conditional refactoring.

The nested if let and if statements have been properly consolidated into a single combined condition using && let syntax. This improves readability while maintaining identical logic and error handling.


184-186: LGTM! Consistent refactoring pattern.

Similar to the previous change, this consolidates nested conditions into a more readable single if let ... && let expression. The refactoring maintains the exact same logic and error handling behavior.

src/daemon/mod.rs (1)

136-137: LGTM! Consistent conditional refactoring.

The nested if and if let statements for snapshot import logic have been properly consolidated into a single combined condition. This maintains the same control flow while improving code readability, consistent with the broader refactoring effort across the codebase.

src/cid_collections/mod.rs (1)

78-81: LGTM! Clean CID validation refactoring.

The multiple validation conditions for CID conversion have been properly consolidated into a single if statement using && let syntax. This improves readability while preserving all validation logic for version, codec, and hash resizing checks.

src/blocks/tipset.rs (1)

430-432: LGTM! Consistent genesis lookup refactoring.

The nested conditions for known block matching in genesis discovery have been properly consolidated using && let syntax. This maintains the same logic for checking known block existence and CID matching while improving code readability.

src/rpc/methods/eth/utils.rs (2)

26-30: LGTM! Clean refactoring of nested conditional.

The nested if let and if statements have been properly combined into a single conditional with a guard clause using &&. This maintains the exact same logic while improving readability.


42-47: LGTM! Consistent conditional refactoring.

Similar to the previous change, this properly combines the nested conditionals into a single if let with a guard condition. The logic remains functionally equivalent while being more concise.

src/rpc/methods/chain.rs (2)

103-112: LGTM! Proper conditional combination for error handling.

The nested conditionals have been correctly combined into a single if statement with &&. This ensures that error logging only occurs when logs are non-empty AND the send operation fails, maintaining the original logic while improving readability.


495-504: LGTM! Clean refactoring of IPLD processing logic.

The nested conditionals for codec checking and IPLD decoding have been properly combined using &&. This maintains the same execution flow where IPLD processing only occurs when the codec is DAG_CBOR AND the decoding succeeds, while making the code more concise.

src/rpc/methods/eth.rs (1)

2507-2518: LGTM – concise error handling for CID→hash conversions

The fused if let chain correctly short-circuits on both the Result and the
Option, and the internal hashing logic is untouched. Nice clean-up.

src/db/gc/snapshot.rs (6)

175-177: LGTM! Clean refactoring of nested conditionals.

The combined if let ... && let pattern improves readability by reducing nesting while maintaining the same functional behavior. This is a good application of Rust's pattern matching capabilities.


178-185: LGTM! Improved conditional logic structure.

The refactored conditions maintain the same logical flow while improving readability by combining the epoch check and trigger send into a single conditional expression. The early-exit behavior on trigger send failure is preserved.


270-272: LGTM! Clean combination of option check and file existence.

The refactoring effectively combines the option extraction and file existence check, reducing nesting and improving code flow. The logic remains functionally identical.


274-292: LGTM! Well-structured column pruning with proper error handling.

The refactored code maintains the retry logic for database column resets and includes appropriate timing measurements and logging. The structure is clean and the error handling is robust.


294-319: LGTM! Comprehensive car file cleanup with proper error handling.

The refactored iterator chain effectively filters and removes old car database files while preserving the blessed snapshot. The error handling is appropriate with informative logging for both successful and failed operations.


322-357: LGTM! Well-structured database backfill with efficient head key management.

The refactored code effectively handles the database backfill process with proper memory management, performance monitoring, and intelligent head key selection. The tuple pattern matching for head key selection is elegant and the fallback logic is sound.

elmattic
elmattic previously approved these changes Aug 8, 2025
Copy link
Copy Markdown
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clippy is a blessing

@elmattic elmattic added this pull request to the merge queue Aug 8, 2025
Merged via the queue into main with commit 3c55295 Aug 8, 2025
43 checks passed
@elmattic elmattic deleted the hm/rust-1.89 branch August 8, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants