Skip to content

fix: resolve Clippy errors from Rust 1.97 lint promotions - #497

Merged
eguzki merged 2 commits into
mainfrom
fix/clippy-rust-1.97
Jul 13, 2026
Merged

fix: resolve Clippy errors from Rust 1.97 lint promotions#497
eguzki merged 2 commits into
mainfrom
fix/clippy-rust-1.97

Conversation

@thomasmaas

@thomasmaas thomasmaas commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace for (_, v) in map.iter() with for v in map.values() (clippy::for_kv_map) in limitador/src/storage/distributed/mod.rs:188
  • Simplify match on Result to use ? operator (clippy::question_mark) in limitador/src/lib.rs:396

Both lints were promoted to clippy::all in Rust 1.97 and now fail under the crate's #![deny(clippy::all)]. This unblocks the merge queue for #491 and any other pending PRs.

Test plan

  • CI Clippy job passes
  • Test suite passes (no behavioral change)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Simplified internal rate-limit checking while preserving existing behaviour and error handling.
    • Streamlined counter retrieval while keeping remaining-limit and expiry calculations unchanged.
  • Chores
    • Adjusted configuration helper annotations to avoid dead-code warnings without changing environment variable behaviour.

Replace `for (_, v) in map.iter()` with `for v in map.values()`
(clippy::for_kv_map) and simplify a match-on-Result to use the `?`
operator (clippy::question_mark). Both lints are now denied under
`#![deny(clippy::all)]` with Rust 1.97.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Thomas Maas <thomas@webtypes.com>
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d201bab4-76f7-4398-b09b-8b5e1a33597f

📥 Commits

Reviewing files that changed from the base of the PR and between 2af8776 and 94b9330.

📒 Files selected for processing (1)
  • limitador-server/src/config.rs

📝 Walkthrough

Walkthrough

Three internal Rust implementations were simplified: rate-limit checking uses an early-return guard, distributed counter retrieval iterates directly over stored values, and an environment helper allows dead-code warnings. Runtime behaviour remains unchanged.

Changes

Rate limiter cleanup

Layer / File(s) Summary
Internal control-flow and counter iteration
limitador/src/lib.rs, limitador/src/storage/distributed/mod.rs
find_first_limited_counter uses ? for error propagation, while get_counters iterates over limits_map values without changing filtering or counter calculations.
Environment helper warning handling
limitador-server/src/config.rs
value_for is annotated with #[allow(dead_code)]; environment-variable parsing remains unchanged.

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

Poem

I’m a rabbit with tidy code,
Hopping through limits on the road.
Errors now swiftly leap away,
Counters count in a cleaner array.
Same results bloom—what a day!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: fixing Clippy errors caused by Rust 1.97 lint promotions.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/clippy-rust-1.97

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.

@eguzki

eguzki commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

There are some clippy errors

error: function `value_for` is never used
  --> limitador-server/src/config.rs:84:8
   |
84 |     fn value_for(env_key: &'static str) -> Option<&'static str> {
   |        ^^^^^^^^^
   |
   = note: `-D dead-code` implied by `-D warnings`
   = help: to override `-D warnings` add `#[expect(dead_code)]` or `#[allow(dead_code)]`

error: function `env_option_is_enabled` is never used
  --> limitador-server/src/config.rs:91:8
   |
91 |     fn env_option_is_enabled(env_name: &str) -> bool {
   |        ^^^^^^^^^^^^^^^^^^^^^

error: could not compile `limitador-server` (bin "limitador-server" test) due to 2 previous errors

Rust 1.97 flags `value_for` and `env_option_is_enabled` as dead code
in test-only compilation targets, even though they are used by
lazy_static! initializers. Add #[allow(dead_code)] to suppress.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Thomas Maas <thomas@webtypes.com>
@thomasmaas

Copy link
Copy Markdown
Contributor Author

Fixed — pushed a second commit that adds #[allow(dead_code)] to value_for and env_option_is_enabled in limitador-server/src/config.rs. These functions are used by lazy_static! initializers but Rust 1.97 flags them as dead code in test-only compilation targets.

@eguzki
eguzki added this pull request to the merge queue Jul 13, 2026
Merged via the queue into main with commit 5f64915 Jul 13, 2026
15 checks passed
@eguzki
eguzki deleted the fix/clippy-rust-1.97 branch July 13, 2026 15:19
@github-project-automation github-project-automation Bot moved this to Done in Kuadrant Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants