fix(backend): resolve clippy lints#109
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis 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.
Confidence Score: 5/5All 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.
|
| 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
Reviews (1): Last reviewed commit: "fix(backend): remove redundant u64 casts..." | Re-trigger Greptile
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.