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

@@ -588,7 +588,7 @@ pub mod tests {
use super::*;
fn make_two_accounts(key: &Pubkey) -> (Account, AccountSharedData) {
let mut account1 = Account::new(1, 2, &key);
let mut account1 = Account::new(1, 2, key);
account1.executable = true;
account1.rent_epoch = 4;
let mut account2 = AccountSharedData::new(1, 2, key);

View File

@@ -46,7 +46,7 @@ impl TryFrom<&str> for DerivationPath {
impl AsRef<[ChildIndex]> for DerivationPath {
fn as_ref(&self) -> &[ChildIndex] {
&self.0.as_ref()
self.0.as_ref()
}
}
@@ -88,7 +88,7 @@ impl DerivationPath {
}
fn _from_absolute_path_insecure_str(path: &str) -> Result<Self, DerivationPathError> {
Ok(Self(DerivationPathInner::from_str(&path).map_err(
Ok(Self(DerivationPathInner::from_str(path).map_err(
|err| DerivationPathError::InvalidDerivationPath(err.to_string()),
)?))
}

View File

@@ -160,7 +160,7 @@ impl GenesisConfig {
}
pub fn load(ledger_path: &Path) -> Result<Self, std::io::Error> {
let filename = Self::genesis_filename(&ledger_path);
let filename = Self::genesis_filename(ledger_path);
let file = OpenOptions::new()
.read(true)
.open(&filename)
@@ -198,7 +198,7 @@ impl GenesisConfig {
std::fs::create_dir_all(&ledger_path)?;
let mut file = File::create(Self::genesis_filename(&ledger_path))?;
let mut file = File::create(Self::genesis_filename(ledger_path))?;
file.write_all(&serialized)
}
@@ -339,8 +339,8 @@ mod tests {
&& account.lamports == 10_000));
let path = &make_tmp_path("genesis_config");
config.write(&path).expect("write");
let loaded_config = GenesisConfig::load(&path).expect("load");
config.write(path).expect("write");
let loaded_config = GenesisConfig::load(path).expect("load");
assert_eq!(config.hash(), loaded_config.hash());
let _ignored = std::fs::remove_file(&path);
}

View File

@@ -306,7 +306,7 @@ mod test {
let authorized = keyed_account.unsigned_key();
keyed_account
.initialize_nonce_account(
&authorized,
authorized,
&recent_blockhashes,
&rent,
&MockInvokeContext::new(vec![]),
@@ -367,7 +367,7 @@ mod test {
keyed_account
.withdraw_nonce_account(
withdraw_lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -597,7 +597,7 @@ mod test {
nonce_keyed
.withdraw_nonce_account(
withdraw_lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -639,7 +639,7 @@ mod test {
let lamports = nonce_keyed.account.borrow().lamports();
let result = nonce_keyed.withdraw_nonce_account(
lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -669,7 +669,7 @@ mod test {
let lamports = nonce_keyed.account.borrow().lamports() + 1;
let result = nonce_keyed.withdraw_nonce_account(
lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -699,7 +699,7 @@ mod test {
nonce_keyed
.withdraw_nonce_account(
withdraw_lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -722,7 +722,7 @@ mod test {
nonce_keyed
.withdraw_nonce_account(
withdraw_lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -779,7 +779,7 @@ mod test {
nonce_keyed
.withdraw_nonce_account(
withdraw_lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -808,7 +808,7 @@ mod test {
nonce_keyed
.withdraw_nonce_account(
withdraw_lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -852,7 +852,7 @@ mod test {
let withdraw_lamports = nonce_keyed.account.borrow().lamports();
let result = nonce_keyed.withdraw_nonce_account(
withdraw_lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -888,7 +888,7 @@ mod test {
let withdraw_lamports = nonce_keyed.account.borrow().lamports() + 1;
let result = nonce_keyed.withdraw_nonce_account(
withdraw_lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -924,7 +924,7 @@ mod test {
let withdraw_lamports = nonce_keyed.account.borrow().lamports() - min_lamports + 1;
let result = nonce_keyed.withdraw_nonce_account(
withdraw_lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -960,7 +960,7 @@ mod test {
let withdraw_lamports = u64::MAX - 54;
let result = nonce_keyed.withdraw_nonce_account(
withdraw_lamports,
&to_keyed,
to_keyed,
&recent_blockhashes,
&rent,
&signers,
@@ -1149,7 +1149,7 @@ mod test {
let authorized = &Pubkey::default().clone();
nonce_account
.initialize_nonce_account(
&authorized,
authorized,
&recent_blockhashes,
&rent,
&MockInvokeContext::new(vec![]),
@@ -1176,7 +1176,7 @@ mod test {
let authorized = nonce_account.unsigned_key();
nonce_account
.initialize_nonce_account(
&authorized,
authorized,
&recent_blockhashes,
&Rent::free(),
&MockInvokeContext::new(vec![]),
@@ -1211,7 +1211,7 @@ mod test {
let authorized = nonce_account.unsigned_key();
nonce_account
.initialize_nonce_account(
&authorized,
authorized,
&recent_blockhashes,
&Rent::free(),
&MockInvokeContext::new(vec![]),

View File

@@ -140,7 +140,7 @@ pub fn verify_eth_addresses(
// Parse out pubkey
let eth_address_slice = get_data_slice(
&instruction_datas,
instruction_datas,
offsets.eth_address_instruction_index,
offsets.eth_address_offset,
HASHED_PUBKEY_SERIALIZED_SIZE,
@@ -148,7 +148,7 @@ pub fn verify_eth_addresses(
// Parse out message
let message_slice = get_data_slice(
&instruction_datas,
instruction_datas,
offsets.message_instruction_index,
offsets.message_data_offset,
offsets.message_data_size as usize,

View File

@@ -29,7 +29,7 @@ impl crate::sanitize::Sanitize for Signature {}
impl Signature {
pub fn new(signature_slice: &[u8]) -> Self {
Self(GenericArray::clone_from_slice(&signature_slice))
Self(GenericArray::clone_from_slice(signature_slice))
}
pub(self) fn verify_verbose(
@@ -54,7 +54,7 @@ pub trait Signable {
}
fn verify(&self) -> bool {
self.get_signature()
.verify(&self.pubkey().as_ref(), self.signable_data().borrow())
.verify(self.pubkey().as_ref(), self.signable_data().borrow())
}
fn pubkey(&self) -> Pubkey;

View File

@@ -459,7 +459,7 @@ pub fn uses_durable_nonce(tx: &Transaction) -> Option<&CompiledInstruction> {
.filter(|maybe_ix| {
let prog_id_idx = maybe_ix.program_id_index as usize;
match message.account_keys.get(prog_id_idx) {
Some(program_id) => system_program::check_id(&program_id),
Some(program_id) => system_program::check_id(program_id),
_ => false,
}
} && matches!(limited_deserialize(&maybe_ix.data), Ok(SystemInstruction::AdvanceNonceAccount))
@@ -968,7 +968,7 @@ mod tests {
let (_, nonce_pubkey, tx) = nonced_transfer_tx();
let nonce_ix = uses_durable_nonce(&tx).unwrap();
assert_eq!(
get_nonce_pubkey_from_instruction(&nonce_ix, &tx),
get_nonce_pubkey_from_instruction(nonce_ix, &tx),
Some(&nonce_pubkey),
);
}