Skip to content

Fix what clippy's deny-level lints found, and the warnings that meant something #279

Closed

Description

@SDL-A1

Migrated from SergioDemianLerner/rustock#279 (pull request by @SDL-A1, 2026-10-07).
Merged: yes. The commits are already in this repository's history.
Original: SergioDemianLerner/rustock#279

Clippy had never run on this workspace: no CI runs it, and the build host had no clippy binary until today. Two lints are deny-by-default, so cargo clippy --workspace did not warn -- it failed, and each failure aborted its crate and hid everything behind it.

The one real bug

// crates/cli/examples/scan_addr.rs:19
let scan_to = tip.max(1_591_001).min(1_591_001);

x.max(N).min(N) is always exactly N. The line above walks exec_head -> header -> number to compute tip and then discards it -- the scan always covered 0..=1_591_001 whatever the node actually held.

Now tip.min(1_591_001): scan to the tip, capped at the Wasabi100 height.

Please confirm the ceiling. 1_591_001 is the constant that was already there, and capping at the tip is the only reading under which computing tip means anything -- but the intended bound is a guess.

The other deny-level hit is not a bug

In merged_mining's tests, (8 / 64) * 64 is the same round-down-to-a-64-byte-block formula as the assertion below it, with the first tag's offset of 8 substituted. It is zero because that tag sits inside the first block, and it is written out rather than as 0 so both assertions read as the same rule.

Allowed with that reason recorded, not collapsed. The attribute binds a local because it does not reach inside the assert_eq! expansion.

Warnings worth acting on

fix where
function items cast straight to an integer, now via the fn-pointer type storage/rskj_import.rs:61,62
flush() whose Result was discarded storage/epoch_store.rs
unused imports (one shadowed by a local use further down) storage/freezer.rs:69, rpc/tests.rs:3413
redundant as u128 on Duration::as_millis() networking/scoring.rs:151
needlessly lazy struct literal -> then_some alerts/watch.rs:164
dead _ => {} after an already-exhaustive match sync/service.rs:3226

Left alone deliberately

  • orchid_converter.rs:176,179 -- the unwraps are provably guarded, and converted0/converted1 are reused at lines 187-195, so satisfying the lint means restructuring consensus trie conversion for no behavioural gain.
  • Four bridge findings are false positives on intentional code. peg.rs:2529 especially: it keeps rskj's three hardfork cases separate even where two coincide, which is precisely what should be preserved. These want #[allow]s with the existing comments, as a separate decision.

Not in this PR

State

cargo clippy --workspace --all-targets now exits 0.

189 warnings remain across 153 unique sites, 68 auto-fixable. That is the first trustworthy count: cargo does not re-emit warnings for cached crates, so earlier partial runs reported 110 and 36 for the same tree. This number came from touching every file under crates/ to force a full re-lint.

cargo test --workspace: 2,046 passed, 0 failed.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions