Fix Nightly Clippy Warnings (backport #18065) (#18070)

* chore: cargo +nightly clippy --fix -Z unstable-options

(cherry picked from commit 6514096a67)

# Conflicts:
#	core/src/banking_stage.rs
#	core/src/cost_model.rs
#	core/src/cost_tracker.rs
#	core/src/execute_cost_table.rs
#	core/src/replay_stage.rs
#	core/src/tvu.rs
#	ledger-tool/src/main.rs
#	programs/bpf_loader/build.rs
#	rbpf-cli/src/main.rs
#	sdk/cargo-build-bpf/src/main.rs
#	sdk/cargo-test-bpf/src/main.rs
#	sdk/src/secp256k1_instruction.rs

* chore: cargo fmt

(cherry picked from commit 789f33e8db)

* Updates BPF program assert_instruction_count tests.

(cherry picked from commit c1e03f3410)

# Conflicts:
#	programs/bpf/tests/programs.rs

* Resolve conflicts

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
mergify[bot]
2021-06-18 20:02:48 +00:00
committed by GitHub
parent c330016109
commit 0e7512a225
173 changed files with 1250 additions and 1056 deletions

View File

@@ -308,10 +308,8 @@ impl Message {
nonce_account_pubkey: &Pubkey,
nonce_authority_pubkey: &Pubkey,
) -> Self {
let nonce_ix = system_instruction::advance_nonce_account(
&nonce_account_pubkey,
&nonce_authority_pubkey,
);
let nonce_ix =
system_instruction::advance_nonce_account(nonce_account_pubkey, nonce_authority_pubkey);
instructions.insert(0, nonce_ix);
Self::new(&instructions, payer)
}
@@ -482,20 +480,20 @@ impl Message {
data: &[u8],
) -> Result<Instruction, SanitizeError> {
let mut current = 0;
let num_instructions = read_u16(&mut current, &data)?;
let num_instructions = read_u16(&mut current, data)?;
if index >= num_instructions as usize {
return Err(SanitizeError::IndexOutOfBounds);
}
// index into the instruction byte-offset table.
current += index * 2;
let start = read_u16(&mut current, &data)?;
let start = read_u16(&mut current, data)?;
current = start as usize;
let num_accounts = read_u16(&mut current, &data)?;
let num_accounts = read_u16(&mut current, data)?;
let mut accounts = Vec::with_capacity(num_accounts as usize);
for _ in 0..num_accounts {
let meta_byte = read_u8(&mut current, &data)?;
let meta_byte = read_u8(&mut current, data)?;
let mut is_signer = false;
let mut is_writable = false;
if meta_byte & (1 << Self::IS_SIGNER_BIT) != 0 {
@@ -504,16 +502,16 @@ impl Message {
if meta_byte & (1 << Self::IS_WRITABLE_BIT) != 0 {
is_writable = true;
}
let pubkey = read_pubkey(&mut current, &data)?;
let pubkey = read_pubkey(&mut current, data)?;
accounts.push(AccountMeta {
pubkey,
is_signer,
is_writable,
});
}
let program_id = read_pubkey(&mut current, &data)?;
let data_len = read_u16(&mut current, &data)?;
let data = read_slice(&mut current, &data, data_len as usize)?;
let program_id = read_pubkey(&mut current, data)?;
let data_len = read_u16(&mut current, data)?;
let data = read_slice(&mut current, data, data_len as usize)?;
Ok(Instruction {
program_id,
accounts,

View File

@@ -17,7 +17,7 @@ pub struct SlotHashes(Vec<SlotHash>);
impl SlotHashes {
pub fn add(&mut self, slot: Slot, hash: Hash) {
match self.binary_search_by(|(probe, _)| slot.cmp(&probe)) {
match self.binary_search_by(|(probe, _)| slot.cmp(probe)) {
Ok(index) => (self.0)[index] = (slot, hash),
Err(index) => (self.0).insert(index, (slot, hash)),
}
@@ -25,7 +25,7 @@ impl SlotHashes {
}
#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn get(&self, slot: &Slot) -> Option<&Hash> {
self.binary_search_by(|(probe, _)| slot.cmp(&probe))
self.binary_search_by(|(probe, _)| slot.cmp(probe))
.ok()
.map(|index| &self[index].1)
}

View File

@@ -139,7 +139,7 @@ impl Authorized {
}
StakeAuthorize::Withdrawer => {
if let Some((lockup, clock, custodian)) = lockup_custodian_args {
if lockup.is_in_force(&clock, None) {
if lockup.is_in_force(clock, None) {
match custodian {
None => {
return Err(StakeError::CustodianMissing.into());
@@ -149,7 +149,7 @@ impl Authorized {
return Err(StakeError::CustodianSignatureMissing.into());
}
if lockup.is_in_force(&clock, Some(custodian)) {
if lockup.is_in_force(clock, Some(custodian)) {
return Err(StakeError::LockupInForce.into());
}
}