Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy: large_enum_variant #4398

Merged

Conversation

brooksprumo
Copy link

Problem

New clippy lints when upgrading to rust 1.84.0.

warning: large size difference between variants
   --> rpc-client-api/src/request.rs:202:1
    |
202 | /  pub enum RpcError {
203 | |      #[error("RPC request error: {0}")]
204 | |      RpcRequestError(String),
    | |      ----------------------- the second-largest variant contains at least 24 bytes
205 | |      #[error("RPC response error {code}: {message}; {data}")]
206 | |/     RpcResponseError {
207 | ||         code: i64,
208 | ||         message: String,
209 | ||         data: RpcResponseErrorData,
210 | ||     },
    | ||_____- the largest variant contains at least 232 bytes
...   |
216 | |      ForUser(String), /* "direct-to-user message" */
217 | |  }
    | |__^ the entire enum is at least 232 bytes
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
    = note: `#[warn(clippy::large_enum_variant)]` on by default
help: consider boxing the large fields to reduce the total size of the enum
    |
209 |         data: Box<RpcResponseErrorData>,
    |               ~~~~~~~~~~~~~~~~~~~~~~~~~

Summary of Changes

Resolve the lints by using the suggestions from clippy and checking the code.

Partially fixes #4380

Copy link

mergify bot commented Jan 10, 2025

If this PR represents a change to the public RPC API:

  1. Make sure it includes a complementary update to rpc-client/ (example)
  2. Open a follow-up PR to update the JavaScript client @solana/web3.js (example)

Thank you for keeping the RPC clients in sync with the server API @brooksprumo.

@brooksprumo brooksprumo marked this pull request as ready for review January 10, 2025 16:39
@brooksprumo brooksprumo added the automerge automerge Merge this Pull Request automatically once CI passes label Jan 10, 2025
@mergify mergify bot merged commit dc67bdc into anza-xyz:master Jan 10, 2025
41 checks passed
@brooksprumo brooksprumo deleted the rust-1.84.0/clippy/large_enum_variant branch January 10, 2025 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New clippy lints in Rust 1.84.0
2 participants