Skip to content

Fix the clippy warnings stable 1.97 reports on main - #224

Merged
aterga merged 1 commit into
mainfrom
arshavir/festive-maxwell-ru67rx
Oct 30, 2026
Merged

aterga merged 1 commit into
mainfrom
arshavir/festive-maxwell-ru67rx

Conversation

@aterga

@aterga aterga commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

cargo clippy --locked --workspace --all-targets on current stable Rust (1.97.0, clippy 0.1.97) reports nine warnings on main, all in imcp2-core code that predates the toolchain's newer lints. CONTRIBUTING.md asks for a warning-free tree, so this applies the minimal change each lint suggests. No behavioural change: every rewrite is the lint's own suggested equivalent, and all surrounding comments are untouched.

Related issues

None.

Changes

  • unnecessary_map_or (5): Option::map_or(false, f) → is_some_and(f) in tools.rs (×3) and discover.rs; map_or(true, f) → is_none_or(f) in calls.rs. Same truth table for None and Some.
  • redundant_closure (1): .map(|h| hex::encode(h)) → .map(hex::encode) in management.rs.
  • cloned_ref_to_slice_refs (1, test): &[at_cap_entity.clone()] → std::slice::from_ref(&at_cap_entity) in calls.rs.
  • manual_repeat_n (2, tests): std::iter::repeat(x).take(n) → std::iter::repeat_n(x, n) in discover.rs.
  • cargo fmt --all then reflowed two of the touched expressions: the repeat_n call in discover.rs no longer fits the 100-column budget and is split across lines, and the module_hash chain in management.rs now fits on one line and is joined.

Testing

All on stable 1.97.0 (rustc 1.97.0 (2d8144b78 2026-07-07), clippy 0.1.97, rustfmt 1.9.0-stable):

  • cargo build --locked --all-targets
  • cargo test --locked --all-targets — 316 tests pass, 0 failed, 0 ignored, across 5 test binaries (imcp2 lib 71, imcp2 bin 8, tests/routers.rs 10, imcp2-core 206, imcp2-local 21)
  • cargo fmt --all / cargo clippy --all-targets (tree is warning-free) — cargo clippy --locked --workspace --all-targets now finishes with zero warnings (nine before this change); cargo fmt --all -- --check passes
  • npm test --prefix monitoring/mcp-status — not applicable, the dashboard is untouched
Clippy before (on main, 7c9964f) and after

Before:

warning: this `map_or` can be simplified            --> crates/imcp2-core/src/tools.rs:2111:16
warning: this `map_or` can be simplified            --> crates/imcp2-core/src/tools.rs:2167:17
warning: this `map_or` can be simplified            --> crates/imcp2-core/src/tools.rs:2169:16
warning: this `map_or` can be simplified            --> crates/imcp2-core/src/calls.rs:1111:26
warning: this `map_or` can be simplified            --> crates/imcp2-core/src/discover.rs:768:5
warning: redundant closure                          --> crates/imcp2-core/src/management.rs:463:22
warning: unnecessary use of `clone` to create a slice from a reference
                                                    --> crates/imcp2-core/src/calls.rs:2879:42
warning: this `repeat().take()` can be written more concisely
                                                    --> crates/imcp2-core/src/discover.rs:3295:13
warning: this `repeat().take()` can be written more concisely
                                                    --> crates/imcp2-core/src/discover.rs:3380:13
warning: `imcp2-core` (lib) generated 6 warnings
warning: `imcp2-core` (lib test) generated 9 warnings (6 duplicates)

After:

    Checking imcp2-core v0.6.0
    Checking imcp2 v0.6.0
    Checking imcp2-local v0.6.0
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.81s

Checklist

  • I have read the Contributing guidelines.
  • Docs (README / comments) updated for any user-visible change. — no user-visible change; no docs affected.
  • No secrets, credentials, or internal-only information are included.

Generated by Claude Code

`cargo clippy --locked --workspace --all-targets` on current stable
Rust (1.97.0, clippy 0.1.97) reports nine warnings on `main`, all in
imcp2-core code that predates the toolchain's newer lints.
CONTRIBUTING.md asks for a warning-free tree, so apply the minimal
change each lint suggests, with no behavioural change:

- `unnecessary_map_or`: `map_or(false, ..)` -> `is_some_and(..)` in
  tools.rs (x3) and discover.rs; `map_or(true, ..)` -> `is_none_or(..)`
  in calls.rs. Same truth table for `None` and `Some`.
- `redundant_closure`: `.map(|h| hex::encode(h))` -> `.map(hex::encode)`
  in management.rs.
- `cloned_ref_to_slice_refs` (test): `&[x.clone()]` ->
  `std::slice::from_ref(&x)` in calls.rs.
- `manual_repeat_n` (tests): `repeat(..).take(n)` -> `repeat_n(.., n)`
  in discover.rs (x2).

`cargo fmt --all` then reflowed two of the touched expressions: the
`repeat_n` call in discover.rs no longer fits the 100-column budget
and is split across lines, and the `module_hash` chain in
management.rs now fits on one line and is joined. Nothing else
changed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VP2vTEywKNq4z23822p8rr
@aterga
aterga requested a balanced review from Copilot October 29, 2026 14:59
@aterga
aterga marked this pull request as ready for review October 29, 2026 14:59
@aterga
aterga requested a review from a team October 29, 2026 14:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the Clippy cleanup.

No open issues 🎉

What changed in this PR

Addresses nine Clippy warnings reported by Rust 1.97 in imcp2-core using equivalent standard-library expressions, with no intended behavior changes.

Changes:

  • Replaces Option::map_or checks with is_some_and or is_none_or.
  • Removes a redundant closure and an unnecessary test clone.
  • Uses repeat_n in test fixtures and applies formatting adjustments.
File Description
crates/​imcp2-core/​src/​tools.rs Simplifies optional host and URL validation checks.
crates/​imcp2-core/​src/​management.rs Passes hex::encode directly when formatting module hashes.
crates/​imcp2-core/​src/​discover.rs Simplifies header validation and repeated test data generation.
crates/​imcp2-core/​src/​calls.rs Simplifies best-match selection and avoids cloning a test entity.

Review effort: Balanced

@aterga
aterga merged commit 9ffb247 into main Oct 30, 2026
17 checks passed
aterga added a commit that referenced this pull request Nov 3, 2026
All three crates share one version. A patch bump: nothing since 0.6.0
changes the crates' public API or refuses anything 0.6.0 allowed. It
carries the mcp_get_delegation retry on a lagging replica (#220), the
bound on what one /oauth/authorize request stores (#221), the reworded
open_app and call tool descriptions and server instructions (#226), and
clippy fixes (#224).

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

4 participants