Repository navigation
Description
Problem
Pre-commit's cargo clippy hook can pass locally and then fail in CI when CI's stable toolchain is newer than the developer's local rustup install. PR #485 hit this — clippy 1.95 introduced clippy::duration_suboptimal_units, which fired on Duration::from_millis(1000) in the new test code. Locally I had rustc 1.93, so pre-commit was clean; CI runs dtolnay/rust-toolchain@stable which resolves to whatever stable is on the runner that day, found 1.95, and the lint failed.
Why pre-commit didn't catch it
rust-toolchain.tomlsayschannel = "stable", butrustuponly updates when the developer runsrustup update. There's no automatic pull oncargoinvocations.dtolnay/rust-toolchain@stablein CI grabs the latest stable on each run from the GitHub-hosted runner image (which itself updates regularly).- Result: a developer who
rustup updated a few months ago gets a clippy that's missing every lint added since — including the one that fails their own PR.
Reproduction
$ rustc --version
rustc 1.93.0 (254b59607 2026-01-19)
$ cargo clippy --workspace --all-targets -- -D warnings
... clean ...
# Push, CI runs clippy 1.95 →
error: constructing a `Duration` using a smaller unit when a larger unit would be more readable
--> crates/cli/src/commands/node_top.rs:776:13
|
776 | Duration::from_millis(1000),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::duration-suboptimal-units` implied by `-D warnings`
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.95.0/index.html#duration_suboptimal_units
Options
- Pin a specific stable in
rust-toolchain.toml(e.g.channel = "1.95.0"). Reproducible, matches the workspace's MSRV-pinning ethos. Cost: someone has to bump it on a cadence, and a renovate/dependabot rule would help. - Pin to a specific stable in the CI workflows too (replace
dtolnay/rust-toolchain@stablewith a specific version). Belt-and-suspenders with option 1. - Add a pre-commit step that runs
rustup update stablefirst. Always-fresh local toolchain. Cost: the first run after a stale period bumps the entire toolchain mid-commit. - Document
rustup update stableas a setup/onboarding step inCONTRIBUTING.mdand rely on developers to refresh manually before pushing. Lighter-weight, partial coverage. - Status quo — accept that pre-commit is best-effort and CI is authoritative. New-clippy-lint surprises are infrequent.
My preference is (1) + (2): pin the toolchain explicitly, and let renovate/dependabot bump it. This matches how the workspace already pins MSRV, and it makes the local-vs-CI equivalence reproducible. (4) is a worthwhile addition either way.
Why this matters now
Hit on PR #485 (feat: \decdn node top`); fixed in commit 61f4703 by replacing the four offending call sites with Duration::from_secs(1)`. The fix was 4-line mechanical, but I had to install rustc 1.95 locally to verify, push again, and wait for CI. That's the kind of round-trip pre-commit was supposed to prevent.
Out of scope
- The pinning conversation should not change MSRV (
rust-version.workspace = true→ 1.85). MSRV is the lower bound we promise to compile on; stable is the upper bound we lint with. Distinct knobs.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
build: pin Rust toolchain to 1.95.0 and bump MSRV to match (#489)