Skip to content

clippy: allow result_large_err in some places#5990

Closed
yihau wants to merge 4 commits intoanza-xyz:masterfrom
yihau:clippy-result-large-err
Closed

clippy: allow result_large_err in some places#5990
yihau wants to merge 4 commits intoanza-xyz:masterfrom
yihau:clippy-result-large-err

Conversation

@yihau
Copy link
Copy Markdown
Member

@yihau yihau commented Apr 25, 2025

Problem

part of nightly rust bumping #5952

https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

I guess fixing this would cause some breaking changes. keep it as is and block newly created

Summary of Changes

allow in some places

@yihau yihau requested a review from brooksprumo April 25, 2025 15:57
@yihau yihau marked this pull request as ready for review April 25, 2025 15:57
@yihau yihau requested a review from a team as a code owner April 25, 2025 15:57
Copy link
Copy Markdown

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Can these annotations be applied on the individual offenders instead of the whole files?

@yihau
Copy link
Copy Markdown
Member Author

yihau commented Apr 25, 2025

yes we can. I thought about that before. since it will be hundreds of lines changes, I tried to use this lazy method to check if I can do less haha. happy to do it right now

@brooksprumo
Copy link
Copy Markdown

[..] since it will be hundreds of lines changes [..]

Oh oof... That's no fun... If you have the clippy log that has all of them, can you upload/paste is here so I can get a sense for it?

@yihau
Copy link
Copy Markdown
Member Author

yihau commented Apr 25, 2025

sure! here is the logs and it just a part of them 🫠

error: the `Err`-variant returned from this function is very large
    --> rpc-client/src/nonblocking/rpc_client.rs:4686:6
     |
4686 | ) -> ClientResult<Vec<(Pubkey, Account)>> {
     |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 256 bytes
     |
     = help: try reducing the size of `solana_rpc_client_api::client_error::Error`, for example by boxing large elements or replacing it with `Box<solana_rpc_client_api::client_error::Error>`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

error: the `Err`-variant returned from this function is very large
   --> rpc-client/src/rpc_client.rs:661:10
    |
661 |     ) -> ClientResult<Signature> {
    |          ^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 256 bytes
    |
    = help: try reducing the size of `solana_rpc_client_api::client_error::Error`, for example by boxing large elements or replacing it with `Box<solana_rpc_client_api::client_error::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

error: the `Err`-variant returned from this function is very large
   --> rpc-client/src/rpc_client.rs:669:10
    |
669 |     ) -> ClientResult<Signature> {
    |          ^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 256 bytes
    |
    = help: try reducing the size of `solana_rpc_client_api::client_error::Error`, for example by boxing large elements or replacing it with `Box<solana_rpc_client_api::client_error::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

error: the `Err`-variant returned from this function is very large
   --> rpc-client/src/rpc_client.rs:680:10
    |
680 |     ) -> ClientResult<Signature> {
    |          ^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 256 bytes
    |
    = help: try reducing the size of `solana_rpc_client_api::client_error::Error`, for example by boxing large elements or replacing it with `Box<solana_rpc_client_api::client_error::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

error: the `Err`-variant returned from this function is very large
   --> rpc-client/src/rpc_client.rs:693:10
    |
693 |     ) -> ClientResult<Signature> {
    |          ^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 256 bytes
    |
    = help: try reducing the size of `solana_rpc_client_api::client_error::Error`, for example by boxing large elements or replacing it with `Box<solana_rpc_client_api::client_error::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

error: the `Err`-variant returned from this function is very large
   --> rpc-client/src/rpc_client.rs:772:10
    |
772 |     ) -> ClientResult<Signature> {
    |          ^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 256 bytes
    |
    = help: try reducing the size of `solana_rpc_client_api::client_error::Error`, for example by boxing large elements or replacing it with `Box<solana_rpc_client_api::client_error::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

error: the `Err`-variant returned from this function is very large
   --> rpc-client/src/rpc_client.rs:857:10
    |
857 |     ) -> ClientResult<Signature> {
    |          ^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 256 bytes
    |
    = help: try reducing the size of `solana_rpc_client_api::client_error::Error`, for example by boxing large elements or replacing it with `Box<solana_rpc_client_api::client_error::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

error: the `Err`-variant returned from this function is very large
   --> rpc-client/src/rpc_client.rs:861:66
    |
861 |     pub fn send<T>(&self, request: RpcRequest, params: Value) -> ClientResult<T>
    |                                                                  ^^^^^^^^^^^^^^^ the `Err`-variant is at least 256 bytes
    |
    = help: try reducing the size of `solana_rpc_client_api::client_error::Error`, for example by boxing large elements or replacing it with `Box<solana_rpc_client_api::client_error::Error>`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.8%. Comparing base (6d5a175) to head (46d7629).
Report is 31 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5990   +/-   ##
=======================================
  Coverage    82.8%    82.8%           
=======================================
  Files         830      830           
  Lines      377256   377256           
=======================================
+ Hits       312529   312596   +67     
+ Misses      64727    64660   -67     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brooksprumo
Copy link
Copy Markdown

sure! here is the logs and it just a part of them 🫠

Great! Can you just annotate the ClientResult and have all these lints go away?

@yihau
Copy link
Copy Markdown
Member Author

yihau commented Apr 28, 2025

no. I tried but no luck 🫠

@yihau
Copy link
Copy Markdown
Member Author

yihau commented Apr 28, 2025

I reverted the previous commit and use a new strategy for adding clippy annotation:

  1. add it to the lib.rs if it's an app
  2. add it to the struct if the error is broadly used or if it belongs to the struct, like ClientError.
  3. add it to individual func

@brooksprumo
Copy link
Copy Markdown

Wait, why didn't we see this clippy lint when upgrading stable rust?

@yihau
Copy link
Copy Markdown
Member Author

yihau commented Apr 28, 2025

Wait, why didn't we see this clippy lint when upgrading stable rust?

oh... we removed stable clippy in #1661. we only run nightly clippy atm

@brooksprumo
Copy link
Copy Markdown

oh... we removed stable clippy in #1661. we only run nightly clippy atm

🫠

Well... that doesn't seem too good. I think we should run clippy in stable again.

We can get these lints resolved (and nightly rust updated) first though.

@yihau
Copy link
Copy Markdown
Member Author

yihau commented Apr 28, 2025

Well... that doesn't seem too good. I think we should run clippy in stable again.

I guess we should force ourselves to update the stable and nightly versions together so that we can ensure clippy issues are caught and save some ci time

and yeah, let's focus on the clippy solving in this PR!

@brooksprumo
Copy link
Copy Markdown

no. I tried but no luck 🫠

Something seems strange. I don't understand why this wouldn't work. Most of the changes that I inspected were all for the ClientResult type. Do you have more information?

Comment thread cli/src/lib.rs Outdated
@@ -1,3 +1,4 @@
#![allow(clippy::result_large_err)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These crate-wide allows are red flags to me. I can't in good conscious sign off on the PR without understanding more why we can't more targeted annotations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I did this because it’s a cli crate. It ideally won’t affect our validator. If you feel it’s too broad, I can spend some time adding annotations to each one

Copy link
Copy Markdown
Member Author

@yihau yihau Apr 30, 2025

Choose a reason for hiding this comment

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

removed crate-wide allow at 46d7629

@yihau
Copy link
Copy Markdown
Member Author

yihau commented Apr 30, 2025

Something seems strange. I don't understand why this wouldn't work. Most of the changes that I inspected were all for the ClientResult type. Do you have more information?

I have no idea. I tried add the annotation to Result and Error but no one works. Maybe the attribute doesn’t get inherited by the function?

You should be able to reproduce this by

cargo +nightly-2025-03-31 clippy --workspace --all-targets --features dummy-for-ci-check,frozen-abi -- --deny=warnings --deny=clippy::default_trait_access --deny=clippy::arithmetic_side_effects --deny=clippy::manual_let_else --deny=clippy::used_underscore_binding

@brooksprumo
Copy link
Copy Markdown

Let's only bump rust nightly to the latest version that matches our stable rust. If we do that, I think we don't need this PR. See #5952 (comment).

@brooksprumo
Copy link
Copy Markdown

Yes, we'll likely need to address this later, when upgrading to rust 1.88.0 though. I think a GH issue can be created and assigned to the owner of the ClientResult for them to determine the correct resolution.

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.

3 participants