fix(backend): resolve clippy lints#107
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 set of Clippy lints across the backend Rust codebase with no functional changes — all fixes are mechanical rewrites that leave runtime behavior identical.
Confidence Score: 5/5All changes are mechanical Clippy fixes with no logic changes; safe to merge. Every change in this PR is a direct, non-functional Clippy correction: removing redundant casts and clones on Copy types, tightening a slice parameter, dropping a double-borrow, boxing a large enum variant, replacing an explicit return, and using the matches! macro. No branching logic, data transformations, or public interfaces are altered. The rename from from_str to from_name is the only potentially broad change, and the single internal call site in event_to_data is correctly updated; the Rust compiler would catch any missed callers. No files require special attention.
|
| Filename | Overview |
|---|---|
| backend/src/bin/client.rs | Removes two redundant as u64 casts on u64–u64 timestamp subtractions; semantics unchanged. |
| backend/src/lib/event_filter.rs | Switches &Vec<T> to &[T] in ArrayPrefixFilter::matches and removes a redundant double-borrow on is_native_transfer. |
| backend/src/lib/event_listener.rs | Renames from_str → from_name (all call sites updated) and uses is_multiple_of(100) in the debug log gate. |
| backend/src/lib/serializable_event.rs | Drops an unnecessary .clone() on a u64 Copy field. |
| backend/src/lib/server.rs | Boxes EventData in EventDataOrMetrics::Event to reduce enum stack footprint; removes explicit return and converts if let boolean pattern to matches!. |
Sequence Diagram
sequenceDiagram
participant Ring as Event Ring
participant Listener as run_event_listener
participant Forwarder as run_event_forwarder_task
participant Broadcast as broadcast::Sender<EventDataOrMetrics>
participant Client as client_write_task (per WS client)
Ring->>Listener: raw ExecEvent
Listener->>Listener: EventName::from_name(name)?
Listener->>Forwarder: EventData (mpsc)
Forwarder->>Forwarder: enrich txn_hash, update TPSTracker
Forwarder->>Broadcast: "EventDataOrMetrics::Event(Box<EventData>)"
alt BlockEnd
Forwarder->>Broadcast: EventDataOrMetrics::TopAccesses(...)
end
alt BlockStart
Forwarder->>Broadcast: EventDataOrMetrics::TPS(...)
end
Broadcast->>Client: EventDataOrMetrics (cloned)
Client->>Client: "process_event -> SerializableEventData::from(&*event_data)"
Client->>Client: filter.matches_event(...)
Client-->>WS: ServerMessage::Events / TopAccesses / TPS (JSON)
Reviews (1): Last reviewed commit: "fix(backend): remove redundant u64 casts..." | Re-trigger Greptile
Replacement for #101, which GitHub marked as merged into the #100 branch before the changes landed on main.\n\nStacked on #106 to keep this PR focused on the backend clippy fixes.