Skip to content

style: fix clippy and deprecation warnings in test and bench targets - #763

Merged
jdx merged 1 commit into
jdx:mainfrom
JamBalaya56562:fix-clippy-test-bench-targets
Aug 1, 2026
Merged

style: fix clippy and deprecation warnings in test and bench targets#763
jdx merged 1 commit into
jdx:mainfrom
JamBalaya56562:fix-clippy-test-bench-targets

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

lint:clippy runs cargo 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-targets currently reports 17 errors on main. This PR fixes all of them. No behaviour changes.

File Count Lint
lib/benches/parse.rs 13 criterion::black_box is deprecated in favour of std::hint::black_box
lib/src/parse.rs (test module) 2 clippy::unnecessary_get_then_check
cli/tests/shell_completions_integration.rs 2 clippy::manual_contains

The 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 warnings is clean.

I deliberately left mise.toml alone: adding --all-targets to lint:clippy would 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), and cargo 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

    • Improved shell completion and mount-related regression test assertions without changing test behavior.
  • Chores

    • Updated benchmark utilities to use the standard library’s recommended optimization helper.

`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.
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The changes simplify two test assertions and replace Criterion’s black_box import with std::hint::black_box. Benchmark registrations and test behavior remain unchanged.

Changes

Test and benchmark cleanup

Layer / File(s) Summary
Direct standard-library checks
cli/tests/shell_completions_integration.rs, lib/src/parse.rs, lib/benches/parse.rs
Zsh completion checks use contains, flag absence uses contains_key, and the benchmark imports black_box from std::hint.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Suggested reviewers: jdx

Poem

A rabbit checks each row with care,
Finds keys and flags laid bare.
black_box hops to standard ground,
While simpler checks go round and round.
Three tiny tweaks, neat as a hare.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the changes that fix Clippy and deprecation warnings in test and benchmark targets.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JamBalaya56562
JamBalaya56562 marked this pull request as ready for review August 1, 2026 13:22
@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR resolves Clippy and deprecation warnings in test and benchmark targets without changing production behavior.

  • Replaces manual iterator equality checks with contains in shell-completion tests.
  • Replaces deprecated criterion::black_box with std::hint::black_box in parser benchmarks.
  • Replaces map get(...).is_none() assertions with contains_key in parser tests.

Confidence Score: 5/5

The 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

Filename Overview
cli/tests/shell_completions_integration.rs Simplifies two exact-string membership assertions while preserving their behavior.
lib/benches/parse.rs Uses the standard-library black-box helper, which is available under the crate’s declared Rust version.
lib/src/parse.rs Rewrites two map-absence assertions using the equivalent contains_key API.

Reviews (1): Last reviewed commit: "style: fix clippy and deprecation warnin..." | Re-trigger Greptile

@jdx
jdx merged commit 80e6d00 into jdx:main Aug 1, 2026
8 checks passed
@mise-en-dev mise-en-dev mentioned this pull request Aug 1, 2026
@JamBalaya56562
JamBalaya56562 deleted the fix-clippy-test-bench-targets branch August 2, 2026 00:26
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Aug 11, 2026
⚠️ **CAUTION: this is a major update, indicating a breaking change!** ⚠️

This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [usage](https://github.com/jdx/usage) | tools | major | `3.5.6` → `5.1.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jdx/usage (usage)</summary>

### [`v5.1.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#510---2026-08-09)

[Compare Source](jdx/usage@v5.0.0...v5.1.0)

##### 🚀 Features

- **(spec)** parse usage comments from strings by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;782](jdx/usage#782)

##### 🐛 Bug Fixes

- **(spec)** avoid inferred metadata from included specs by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;786](jdx/usage#786)

##### 🧪 Testing

- **(windows)** make the suite runnable on Windows by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;771](jdx/usage#771)

##### 📦️ Dependency Updates

- update rust crate rmcp to v3 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;780](jdx/usage#780)

### [`v5.0.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#500---2026-08-02)

[Compare Source](jdx/usage@v4.1.0...v5.0.0)

##### 🚀 Features

- **(cli)** allow overriding the shell program with USAGE\_SHELL\_<SHELL> by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;767](jdx/usage#767)

##### 🐛 Bug Fixes

- **(cli)** forward parsed args to WSL bash via WSLENV on windows by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;764](jdx/usage#764)
- **(cli)** let generate markdown write to stdout by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;766](jdx/usage#766)
- **(complete)** use `type -P` so the CLI-presence guard ignores shell functions by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;760](jdx/usage#760)
- **(parse)** enforce double\_dash="required" for positional args by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;762](jdx/usage#762)
- **(windows)** run `run=` scripts with sh when available by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;765](jdx/usage#765)

##### 🎨 Styling

- fix clippy and deprecation warnings in test and bench targets by [@&#8203;JamBalaya56562](https://github.com/JamBalaya56562) in [#&#8203;763](jdx/usage#763)

### [`v4.1.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#410---2026-07-30)

[Compare Source](jdx/usage@v4.0.0...v4.1.0)

##### 🚀 Features

- **(cli)** declare what each usage command does to the world by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;751](jdx/usage#751)
- **(mcp)** serve a usage spec to an agent over stdio by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;746](jdx/usage#746)
- **(spec)** add a top-level `repository` field by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;747](jdx/usage#747)

##### 🐛 Bug Fixes

- **(parse)** keep a re-declared global's aliases on one flag by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;752](jdx/usage#752)
- complete repeated variadic args by [@&#8203;Jai-JAP](https://github.com/Jai-JAP) in [#&#8203;753](jdx/usage#753)

##### New Contributors

- [@&#8203;Jai-JAP](https://github.com/Jai-JAP) made their first contribution in [#&#8203;753](jdx/usage#753)

### [`v4.0.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#400---2026-07-25)

[Compare Source](jdx/usage@v3.6.0...v4.0.0)

##### 🚀 Features

- **(spec)** allow effect= on flags and args by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;742](jdx/usage#742)

### [`v3.6.0`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#360---2026-07-25)

[Compare Source](jdx/usage@v3.5.7...v3.6.0)

##### 🚀 Features

- **(spec)** add effect= to declare what a command does to the world by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;739](jdx/usage#739)

##### 🚜 Refactor

- **(spec)** make missed SpecCommand fields a compile error, and fix the four that were already missed by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;740](jdx/usage#740)

### [`v3.5.7`](https://github.com/jdx/usage/blob/HEAD/CHANGELOG.md#357---2026-07-25)

[Compare Source](jdx/usage@v3.5.6...v3.5.7)

##### 🐛 Bug Fixes

- **(parse)** don't leak the mounting CLI's flags into mounted commands; scan past non-global flags by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;738](jdx/usage#738)

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yODguMCIsInVwZGF0ZWRJblZlciI6IjQzLjI4OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWFqb3IiXX0=-->
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.

2 participants