Reformat imports to a consistent style for imports

rustfmt.toml configuration:
  imports_granularity = "One"
  group_imports = "One"
This commit is contained in:
Michael Vines
2021-12-03 09:00:31 -08:00
parent 0ef1b25e4b
commit b8837c04ec
397 changed files with 5990 additions and 5175 deletions

View File

@@ -1,21 +1,23 @@
#![allow(clippy::integer_arithmetic)]
//! A library for generating a message from a sequence of instructions
use crate::sanitize::{Sanitize, SanitizeError};
use crate::serialize_utils::{
append_slice, append_u16, append_u8, read_pubkey, read_slice, read_u16, read_u8,
use {
crate::{
bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
hash::Hash,
instruction::{AccountMeta, CompiledInstruction, Instruction},
message::MessageHeader,
pubkey::Pubkey,
sanitize::{Sanitize, SanitizeError},
serialize_utils::{
append_slice, append_u16, append_u8, read_pubkey, read_slice, read_u16, read_u8,
},
short_vec, system_instruction, system_program, sysvar,
},
itertools::Itertools,
lazy_static::lazy_static,
std::{convert::TryFrom, str::FromStr},
};
use crate::{
bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable,
hash::Hash,
instruction::{AccountMeta, CompiledInstruction, Instruction},
message::MessageHeader,
pubkey::Pubkey,
short_vec, system_instruction, system_program, sysvar,
};
use itertools::Itertools;
use lazy_static::lazy_static;
use std::{convert::TryFrom, str::FromStr};
lazy_static! {
// Copied keys over since direct references create cyclical dependency.
@@ -526,9 +528,11 @@ impl Message {
#[cfg(test)]
mod tests {
#![allow(deprecated)]
use super::*;
use crate::{hash, instruction::AccountMeta, message::MESSAGE_HEADER_LENGTH};
use std::collections::HashSet;
use {
super::*,
crate::{hash, instruction::AccountMeta, message::MESSAGE_HEADER_LENGTH},
std::collections::HashSet,
};
#[test]
fn test_message_unique_program_ids() {

View File

@@ -114,7 +114,8 @@ impl MappedMessage {
/// Returns true if the account at the specified index is called as a program by an instruction
pub fn is_key_called_as_program(&self, key_index: usize) -> bool {
if let Ok(key_index) = u8::try_from(key_index) {
self.message.instructions
self.message
.instructions
.iter()
.any(|ix| ix.program_id_index == key_index)
} else {
@@ -131,9 +132,11 @@ impl MappedMessage {
#[cfg(test)]
mod tests {
use super::*;
use crate::{instruction::CompiledInstruction, message::MessageHeader, system_program, sysvar};
use itertools::Itertools;
use {
super::*,
crate::{instruction::CompiledInstruction, message::MessageHeader, system_program, sysvar},
itertools::Itertools,
};
fn create_test_mapped_message() -> (MappedMessage, [Pubkey; 6]) {
let key0 = Pubkey::new_unique();
@@ -279,13 +282,11 @@ mod tests {
num_readonly_unsigned_accounts: 0,
},
account_keys: vec![key0],
instructions: vec![
CompiledInstruction {
program_id_index: 2,
accounts: vec![1],
data: vec![],
}
],
instructions: vec![CompiledInstruction {
program_id_index: 2,
accounts: vec![1],
data: vec![],
}],
..v0::Message::default()
},
mapped_addresses: MappedAddresses {

View File

@@ -10,13 +10,10 @@ mod non_bpf_modules {
pub mod v0;
mod versions;
pub use mapped::*;
pub use sanitized::*;
pub use versions::*;
pub use {mapped::*, sanitized::*, versions::*};
}
pub use legacy::Message;
#[cfg(not(target_arch = "bpf"))]
pub use non_bpf_modules::*;

View File

@@ -300,10 +300,12 @@ impl SanitizedMessage {
#[cfg(test)]
mod tests {
use super::*;
use crate::{
instruction::{AccountMeta, Instruction},
message::v0,
use {
super::*,
crate::{
instruction::{AccountMeta, Instruction},
message::v0,
},
};
#[test]

View File

@@ -127,8 +127,7 @@ impl Message {
#[cfg(test)]
mod tests {
use super::*;
use crate::message::VersionedMessage;
use {super::*, crate::message::VersionedMessage};
fn simple_message() -> Message {
Message {

View File

@@ -10,7 +10,7 @@ use {
serde::{
de::{self, Deserializer, SeqAccess, Visitor},
ser::{SerializeTuple, Serializer},
{Deserialize, Serialize},
Deserialize, Serialize,
},
std::fmt,
};
@@ -243,10 +243,12 @@ impl<'de> Deserialize<'de> for VersionedMessage {
#[cfg(test)]
mod tests {
use super::*;
use crate::{
instruction::{AccountMeta, Instruction},
message::v0::AddressMapIndexes,
use {
super::*,
crate::{
instruction::{AccountMeta, Instruction},
message::v0::AddressMapIndexes,
},
};
#[test]