Skip to content

clippy: uninlined_format_args#6854

Closed
steviez wants to merge 4 commits intoanza-xyz:masterfrom
steviez:rust_v1.88_clippy
Closed

clippy: uninlined_format_args#6854
steviez wants to merge 4 commits intoanza-xyz:masterfrom
steviez:rust_v1.88_clippy

Conversation

@steviez
Copy link
Copy Markdown

@steviez steviez commented Jul 6, 2025

Problem

Work towards #6850 - it appears that using variables inline in format! is now required. Sample error output:

error: variables can be used directly in the `format!` string
 --> version/build.rs:8:17
  |
8 |                 println!("cargo:rustc-env=AGAVE_GIT_COMMIT_HASH={}", trimmed_hash);
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
  = note: `-D clippy::uninlined-format-args` implied by `-D warnings`
  = help: to override `-D warnings` add `#[allow(clippy::uninlined_format_args)]`
help: change this to
  |
8 -                 println!("cargo:rustc-env=AGAVE_GIT_COMMIT_HASH={}", trimmed_hash);
8 +                 println!("cargo:rustc-env=AGAVE_GIT_COMMIT_HASH={trimmed_hash}");
  |

Summary of Changes

The steps to create this PR:

  1. Setting version in rust-toolchain.toml to 1.88.0
  2. Run cargo clippy --fix --allow-dirty
  3. Manually revert several changes that were not uninlined_format_args complaints
  4. Add all changed files to first commit
  5. Run ./cargo nightly fmt to cleanup strings modified in 1st commit
  6. Run cargo clippy --fix --tests --allow-dirty
  7. Run cargo nightly fmt to cleanup strings modified in 3rd commit

@steviez steviez requested a review from a team as a code owner July 6, 2025 23:05
@mergify
Copy link
Copy Markdown

mergify Bot commented Jul 6, 2025

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

@steviez steviez requested a review from a team as a code owner July 6, 2025 23:35
@mergify
Copy link
Copy Markdown

mergify Bot commented Jul 6, 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/kit (example)

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

Copy link
Copy Markdown
Author

@steviez steviez left a comment

Choose a reason for hiding this comment

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

Build is currently failing since fmt differs; however, I think the change it wants to adopt is kind of ridiculous. See here:
https://buildkite.com/anza/agave/builds/26034#0197e23a-a436-4805-ad12-6f69c1e9500f

Note the misalignment of the parentheses for trace!; might play around with it for a little but also might cave and just let it go with the misalignment:
image

debug!(
"Loaded Programs Cache Stats -- Hits: {}, Misses: {}, Evictions: {}, Reloads: {}, Insertions: {}, Lost-Insertions: {}, Replacements: {}, One-Hit-Wonders: {}, Prunes-Orphan: {}, Prunes-Environment: {}, Empty: {}, Water-Level: {}",
hits, misses, evictions, reloads, insertions, lost_insertions, replacements, one_hit_wonders, prunes_orphan, prunes_environment, empty_entries, water_level
"Loaded Programs Cache Stats -- Hits: {hits}, Misses: {misses}, Evictions: {evictions}, Reloads: {reloads}, Insertions: {insertions}, Lost-Insertions: {lost_insertions}, Replacements: {replacements}, One-Hit-Wonders: {one_hit_wonders}, Prunes-Orphan: {prunes_orphan}, Prunes-Environment: {prunes_environment}, Empty: {empty_entries}, Water-Level: {water_level}"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not going to touch it as part of this PR, but this string is clearly too long and could be causing issues with cargo fmt for the whole file. Just calling out

debug!(
"Too many requests: server responded with {:?}, {} retries left, pausing for {:?}",
response, too_many_requests_retries, duration
"Too many requests: server responded with {response:?}, {too_many_requests_retries} retries left, pausing for {duration:?}"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Another malformed line that we should clean up after this PR

max_streams_per_interval: {max_streams_per_throttling_interval}, read_interval_streams: {streams_read_in_throttle_interval} \
throttle_duration: {throttle_duration:?}",
peer_type, total_stake);
throttle_duration: {throttle_duration:?}");
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Another case: the indentation on these subsequent line looks off

Comment on lines -140 to +141
error!("Failed to deploy the program: {}", e);
format!("Failed to deploy the program: {}", e)
error!("Failed to deploy the program: {e}");
format!("Failed to deploy the program: {e}")
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

For future - could probably create the string once, print it in error log and then return to avoid the double format!()

Comment on lines -157 to +158
error!("Failed to fetch the program: {}", e);
format!("Failed to fetch the program: {}", e)
error!("Failed to fetch the program: {e}");
format!("Failed to fetch the program: {e}")
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Same as above - can seemingly get this down to a single format!()

LucasSte
LucasSte previously approved these changes Jul 7, 2025
Copy link
Copy Markdown

@LucasSte LucasSte left a comment

Choose a reason for hiding this comment

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

I skimmed through the files.

Comment thread runtime/src/bank.rs
Comment on lines +4147 to +4148
let diff = new_account.lamports() - old_account.lamports();
trace!("store_account_and_update_capitalization: increased: {pubkey} {diff}");
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fmt was doing some weird stuff with the formatting here. Renaming increased ==> diff (and decreased ==> diff below) avoided it. Typically, I would prefer not to rename variables in a PR like this, but if you look at the 3rd commit, fmt was making a mess of it

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 51.49606% with 308 lines in your changes missing coverage. Please review.

Project coverage is 83.2%. Comparing base (833b05b) to head (6d1998b).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #6854    +/-   ##
========================================
  Coverage    83.2%    83.2%            
========================================
  Files         852      852            
  Lines      376951   376839   -112     
========================================
- Hits       313888   313866    -22     
+ Misses      63063    62973    -90     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@steviez steviez requested a review from brooksprumo July 9, 2025 06:47
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.

Let no good deed go unpunished!

I made it up until cli/. IMO this PR is too large. I worry that it'll constantly require handling merge conflicts. That or it just gets stamped without someone doing a full review.

Maybe it is split up into smaller chunks with a few crates at a time?

info!(
"total_accounts_created: {} total_accounts_closed: {} tx_sent_count: {} loop_count: {} balance(s): {:?}",
total_accounts_created, total_accounts_closed, tx_sent_count, count, balances
"total_accounts_created: {total_accounts_created} total_accounts_closed: {total_accounts_closed} tx_sent_count: {tx_sent_count} loop_count: {count} balance(s): {balances:?}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This line is significantly longer than 100 characters. Granted it was longer than 100 characters before too...

info!(
"total_accounts_closed: {} tx_sent_count: {} loop_count: {} balance(s): {:?}",
total_accounts_closed, tx_sent_count, count, balances
"total_accounts_closed: {total_accounts_closed} tx_sent_count: {tx_sent_count} loop_count: {count} balance(s): {balances:?}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Longer than 100 characters now, where as it wasn't before.

#[allow(clippy::stable_sort_primitive)]
alive_roots.sort();
info!("{}: accounts_index alive_roots: {:?}", label, alive_roots,);
info!("{label}: accounts_index alive_roots: {alive_roots:?}",);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: not caused by you, but the trailing comma.

Suggested change
info!("{label}: accounts_index alive_roots: {alive_roots:?}",);
info!("{label}: accounts_index alive_roots: {alive_roots:?}");

if result.is_err() {
// for vm.max_map_count, error is: {code: 12, kind: Other, message: "Cannot allocate memory"}
info!("memory map error: {:?}. This may be because vm.max_map_count is not set correctly.", result);
info!("memory map error: {result:?}. This may be because vm.max_map_count is not set correctly.");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Longer than 100 characters. Old was too.

entry_size,
limit_size,
);
trace!("checked_total_size_sum: {total_size} + {entry_size} < {limit_size}",);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

trailing comma.

Comment thread bench-tps/src/bench.rs
info!(
"Funding keypair balance: {} max_fee: {} lamports_per_account: {} extra: {} total: {}",
funding_key_balance, max_fee, lamports_per_account, extra, total
"Funding keypair balance: {funding_key_balance} max_fee: {max_fee} lamports_per_account: {lamports_per_account} extra: {extra} total: {total}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Longer than 100 characters.

warn!(
"Too many failed transfers... {} remaining, {} verified, {} failures",
remaining_count, verified_txs, failed_verify
"Too many failed transfers... {remaining_count} remaining, {verified_txs} verified, {failed_verify} failures"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Longer than 100 characters.

info!(
"Verifying transfers... {} remaining, {} verified, {} failures",
remaining_count, verified_txs, failed_verify
"Verifying transfers... {remaining_count} remaining, {verified_txs} verified, {failed_verify} failures"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Longer than 100 characters.

info!(
"Verifying transfers... {} remaining, {} verified, {} failures",
remaining_count, verified_txs, failed_verify
"Verifying transfers... {remaining_count} remaining, {verified_txs} verified, {failed_verify} failures"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Longer than 100 characters.

@steviez
Copy link
Copy Markdown
Author

steviez commented Jul 10, 2025

Let no good deed go unpunished!

As is tradition

I made it up until cli/. IMO this PR is too large. I worry that it'll constantly require handling merge conflicts. That or it just gets stamped without someone doing a full review.

I did review this one somewhat myself and was hoping I'd find another brave soul who could slog through it, but given that you found some other >100 character offenders, maybe we can break it up

Maybe it is split up into smaller chunks with a few crates at a time?

Appreciate you helping me pump my commit numbers 😆

@steviez
Copy link
Copy Markdown
Author

steviez commented Jul 10, 2025

Going to close this out in favor of smaller PR's

I made it up until cli/. IMO this PR is too large.

Sorry about any wasted efforts here Brooks. And similar sentiment for you @LucasSte; I broke the SVM owned stuff into separate PR (#6910) to hopefully avoid requiring multiple re-reviews from you & team

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.

4 participants