Skip to content

fix(backend): resolve clippy lints#109

Merged
Camillebzd merged 3 commits into
mainfrom
reopen/101-backend-clippy-main
Jun 11, 2026
Merged

fix(backend): resolve clippy lints#109
Camillebzd merged 3 commits into
mainfrom
reopen/101-backend-clippy-main

Conversation

@kyscott18

Copy link
Copy Markdown
Contributor

Replacement for #101, which GitHub marked as merged into a non-main branch before the changes landed on main.\n\nThis is rebuilt from current main and contains only the backend clippy fixes. Merge this before #106 so the Rust CI job introduced there is green.

Addresses 6 of the 8 clippy findings surfaced by the new rust CI job:
- needless_return (server.rs)
- match_like_matches_macro (server.rs)
- ptr_arg: &Vec<T> -> &[T] (event_filter.rs)
- needless_borrow (event_filter.rs)
- manual_is_multiple_of (event_listener.rs)
- clone_on_copy (serializable_event.rs)

Remaining (require manual judgment, deferred): large_enum_variant
(server.rs), should_implement_trait for from_str (event_listener.rs).
- large_enum_variant: box the 640-byte Event variant of EventDataOrMetrics
  (Event(Box<EventData>)). Since From::from infers its parameter type from
  the argument (deref coercion does not apply), the match-site call passes
  &*event_data to select From<&EventData>; construction uses Box::new(..).
- should_implement_trait: rename inherent EventName::from_str -> from_name
  (and its single caller) so it no longer shadows std::str::FromStr::from_str.
Surfaced once the lib compiled clean: timestamp_ns is u64, so the
(u64 - u64) as u64 casts are redundant; drop the cast and parens.
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
monode Ready Ready Preview, Comment Jun 11, 2026 3:38pm

Request Review

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR resolves a batch of Clippy lints across five backend Rust files ahead of a CI job that enforces them. All changes are mechanical, lint-driven cleanups with no business logic alterations.

  • client.rs / serializable_event.rs: Removes two redundant as u64 casts and a no-op .clone() on a Copy type.
  • event_filter.rs: Tightens matches from &Vec<T> to &[T] and drops a needless double-reference.
  • event_listener.rs: Renames from_strfrom_name, updates its call site, and replaces % 100 == 0 with is_multiple_of(100).
  • server.rs: Boxes EventData in the enum variant, removes an explicit return, and replaces an if-let-else with matches!.

Confidence Score: 5/5

All five files contain mechanical, lint-driven cleanups with no logic changes; safe to merge.

Every change responds to a specific Clippy lint: redundant casts and clones on Copy types, a slice-argument tightening, a method rename to avoid a trait-naming clash, and boxing a large enum payload to shrink the broadcast channel memory footprint. No control-flow paths, data contracts, or observable behaviors change. The one new API (is_multiple_of) has been stable since Rust 1.79 and the project builds on 1.91.

No files require special attention.

Important Files Changed

Filename Overview
backend/src/bin/client.rs Removes two redundant as u64 casts on u64 arithmetic; no behavior change.
backend/src/lib/event_filter.rs Tightens matches argument from &Vec to &[T] and removes a double-reference; idiomatic cleanups with no semantic change.
backend/src/lib/event_listener.rs Renames from_str to from_name, updates the single call site, and replaces % 100 == 0 with is_multiple_of(100); behaviorally equivalent.
backend/src/lib/serializable_event.rs Drops a redundant .clone() on a Copy type (u64); no behavior change.
backend/src/lib/server.rs Boxes EventData in the enum variant, drops an explicit return, and replaces if-let-else with matches!; logic unchanged.

Sequence Diagram

sequenceDiagram
    participant ER as EventRing (thread)
    participant EL as EventListener
    participant EF as run_event_forwarder_task
    participant BC as broadcast::channel (1M capacity)
    participant CW as client_write_task
    participant WS as WebSocket Client

    ER->>EL: EventDescriptor ready
    EL->>EL: event_to_data() to EventData
    EL->>EF: mpsc send EventData
    EF->>EF: populate txn_hash, update TPSTracker
    EF->>BC: send Event(Box::new(event_data))
    EF-->>BC: send TPS on BlockStart
    EF-->>BC: send TopAccesses on BlockEnd
    BC-->>CW: broadcast recv
    CW->>CW: process_event filter events_buf
    CW->>WS: send batched ServerMessage Events
Loading

Reviews (1): Last reviewed commit: "fix(backend): remove redundant u64 casts..." | Re-trigger Greptile

@Camillebzd Camillebzd merged commit e333273 into main Jun 11, 2026
7 checks passed
@Camillebzd Camillebzd deleted the reopen/101-backend-clippy-main branch June 11, 2026 15:59
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