style: fix clippy and deprecation warnings in test and bench targets - #763
style: fix clippy and deprecation warnings in test and bench targets#763JamBalaya56562 wants to merge 1 commit into
Conversation
`lint:clippy` runs `cargo clippy --all --all-features -- -D warnings`, which does not cover test, bench or example targets. Nothing was linting them, so they had drifted: - `lib/benches/parse.rs` used `criterion::black_box`, deprecated in favour of `std::hint::black_box`. Importing it from `std::hint` fixes all 13 call sites without touching them. - `lib/src/parse.rs` used `get(k).is_none()` where `!contains_key(k)` says the same thing (`clippy::unnecessary_get_then_check`). - `cli/tests/shell_completions_integration.rs` used `iter().any(|l| *l == x)` where `contains(&x)` is equivalent and cheaper (`clippy::manual_contains`). `cargo clippy --all --all-features --all-targets -- -D warnings` is now clean. No behaviour changes.
📝 WalkthroughWalkthroughThe changes simplify two test assertions and replace Criterion’s ChangesTest and benchmark cleanup
Estimated code review effort: 1 (Trivial) | ~3 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR resolves Clippy and deprecation warnings in test and benchmark targets without changing production behavior.
Confidence Score: 5/5The PR appears safe to merge with no actionable defects identified. The assertion rewrites preserve membership semantics, and the benchmark helper replacement is supported by the repository’s declared Rust toolchain. Important Files Changed
Reviews (1): Last reviewed commit: "style: fix clippy and deprecation warnin..." | Re-trigger Greptile |
lint:clippyrunscargo clippy --all --all-features -- -D warnings, which does not cover test, bench or example targets. Nothing has been linting them, so they had drifted —--all-targetscurrently reports 17 errors onmain. This PR fixes all of them. No behaviour changes.lib/benches/parse.rscriterion::black_boxis deprecated in favour ofstd::hint::black_boxlib/src/parse.rs(test module)clippy::unnecessary_get_then_checkcli/tests/shell_completions_integration.rsclippy::manual_containsThe bench fix is a one-line import change —
use std::hint::black_box;— so all 13 call sites stay as they are.After this,
cargo clippy --all --all-features --all-targets -- -D warningsis clean.I deliberately left
mise.tomlalone: adding--all-targetstolint:clippywould keep this from drifting again, but that is a CI policy change and felt like a separate conversation. Happy to send it as a follow-up if you want it.Verified with
cargo test -p usage-lib --all-features,cargo bench -p usage-lib --no-run(the bench builds and links), andcargo fmt --all -- --check. The shell-completion integration tests only compile-check locally — they need Unix shells — so CI is the real check there.This pull request was generated by Claude Code.
Summary by CodeRabbit
Tests
Chores