Uh oh!
There was an error while loading. Please reload this page.
chore: enable ref-option* lints - #6740
Conversation
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughReplaced multiple occurrences of Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
✨ Simplify code
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/db/car/forest.rs (1)
121-135: Please document the publicmetadatamethod.Line 121 introduces/updates a public API signature but still lacks a doc comment.
💡 Proposed doc comment
+ /// Returns snapshot metadata for v2 snapshots, if present and decodable.+ ///+ /// Returns `None` for v1 snapshots or when metadata is unavailable. pub fn metadata(&self) -> Option<&FilecoinSnapshotMetadata> {As per coding guidelines:
Document public functions and structs with doc comments.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/db/car/forest.rs` around lines 121 - 135, Add a doc comment to the public method metadata describing what it does and its return value: explain that forest::Car::metadata lazily initializes and returns an Option<&FilecoinSnapshotMetadata>, that it attempts to read metadata from header.roots when the snapshot has V2 root count (super::V2_SNAPSHOT_ROOT_COUNT), calls get_cbor::<FilecoinSnapshotMetadata> on the first root CID and returns Some(metadata) on success or None otherwise, and note that the returned reference is cached for the lifetime of the CAR instance.src/db/car/any.rs (1)
57-63: Add a doc comment for the publicmetadataAPI.Line 57 changes a public method signature, but the method is still undocumented.
💡 Proposed doc comment
+ /// Returns snapshot metadata if present in the underlying CAR variant.+ ///+ /// For CAR files without v2 metadata, this returns `None`. pub fn metadata(&self) -> Option<&FilecoinSnapshotMetadata> {As per coding guidelines:
Document public functions and structs with doc comments.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/db/car/any.rs` around lines 57 - 63, Add a doc comment above the public method AnyCar::metadata describing what it returns and when it can be None; update the doc to mention the return type (Option<&FilecoinSnapshotMetadata>) and that it delegates to the specific variants (Forest, Plain, Memory) via forest.metadata(), plain.metadata(), mem.metadata(), so callers know the semantic meaning and nullability of the metadata value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/db/car/plain.rs`:
- Around line 176-189: Add a doc comment to the public method metadata() that
explains the two distinct reasons it can return None: (1) the CAR is not a v2
snapshot (check uses header_v1.roots.len() == super::V2_SNAPSHOT_ROOT_COUNT) and
(2) the metadata CID existed but loading/decoding via
get_cbor::<FilecoinSnapshotMetadata>(...) failed or returned None; reference
FilecoinSnapshotMetadata, header_v1.roots, V2_SNAPSHOT_ROOT_COUNT and get_cbor
in the comment so callers know how to interpret None.
In `@src/rpc/methods/chain.rs`:
- Around line 1067-1070: Add a doc comment above the public function
get_tipset_by_anchor explaining its fallback contract: when the anchor parameter
is None the function resolves to the finalized Tipset, when an explicit
TipsetAnchor is provided but represents a zero/empty anchor it falls back to the
heaviest Tipset, and otherwise it resolves according to the provided
TipsetAnchor; reference the TipsetAnchor and Tipset types in the comment so
callers understand the exact behavior.
In `@src/shim/actors/convert.rs`:
- Around line 93-96: Add a doc comment to the public function
from_opt_token_v4_to_v2 describing its behavior: explain that it converts a
TokenAmountV4 (by reference) to TokenAmountV2 and that when passed None it
returns TokenAmountV2::default(); include the rationale/intent and any
guarantees (e.g., cloning atto value via TokenAmountV2::from_atto) so callers
understand the fallback behavior and conversion semantics, following the crate's
doc-comment guideline for public APIs.
---
Nitpick comments:
In `@src/db/car/any.rs`:
- Around line 57-63: Add a doc comment above the public method AnyCar::metadata
describing what it returns and when it can be None; update the doc to mention
the return type (Option<&FilecoinSnapshotMetadata>) and that it delegates to the
specific variants (Forest, Plain, Memory) via forest.metadata(),
plain.metadata(), mem.metadata(), so callers know the semantic meaning and
nullability of the metadata value.
In `@src/db/car/forest.rs`:
- Around line 121-135: Add a doc comment to the public method metadata
describing what it does and its return value: explain that forest::Car::metadata
lazily initializes and returns an Option<&FilecoinSnapshotMetadata>, that it
attempts to read metadata from header.roots when the snapshot has V2 root count
(super::V2_SNAPSHOT_ROOT_COUNT), calls get_cbor::<FilecoinSnapshotMetadata> on
the first root CID and returns Some(metadata) on success or None otherwise, and
note that the returned reference is cached for the lifetime of the CAR instance.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: aa319cc0-3189-4ce9-8152-ed7d12027c17
📒 Files selected for processing (20)
Cargo.tomlinterop-tests/Cargo.tomlsrc/chain/tests.rssrc/cli/subcommands/mpool_cmd.rssrc/daemon/db_util.rssrc/db/car/any.rssrc/db/car/forest.rssrc/db/car/plain.rssrc/eth/eip_1559_transaction.rssrc/eth/eip_155_transaction.rssrc/eth/homestead_transaction.rssrc/eth/transaction.rssrc/ipld/tests/selector_explore.rssrc/rpc/methods/chain.rssrc/rpc/methods/eth.rssrc/rpc/methods/eth/filter/mod.rssrc/rpc/methods/eth/types.rssrc/rpc/types/tipset_selector.rssrc/shim/actors/convert.rssrc/utils/net/download_file.rs
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary of changes
Changes introduced in this pull request:
ref_optionclippy lintsReference issue to close (if applicable)
Closes
Other information and links
https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#ref_option
https://www.youtube.com/watch?v=6c7pZYP_iIE
Change checklist
Outside contributions
Summary by CodeRabbit
Refactor
Chores