Skip to content

Commit

Permalink
Preliminary Changes for Updating Cargo (solana-labs#32547)
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge authored Jul 21, 2023
1 parent 952d886 commit a7eda70
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion frozen-abi/src/abi_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl<T: AbiExample> AbiExample for Box<[T]> {
impl<T: AbiExample> AbiExample for std::marker::PhantomData<T> {
fn example() -> Self {
info!("AbiExample for (PhantomData<T>): {}", type_name::<Self>());
<std::marker::PhantomData<T>>::default()
std::marker::PhantomData::<T>
}
}

Expand Down
2 changes: 1 addition & 1 deletion net-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ mod tests {
let address = IpAddr::from([
525u16, 524u16, 523u16, 522u16, 521u16, 520u16, 519u16, 518u16,
]);
let mut data = vec![0u8; IP_ECHO_SERVER_RESPONSE_LENGTH];
let mut data = [0u8; IP_ECHO_SERVER_RESPONSE_LENGTH];
bincode::serialize_into(&mut data[HEADER_LENGTH..], &address).unwrap();
let response: Result<IpEchoServerResponse, _> =
bincode::deserialize(&data[HEADER_LENGTH..]);
Expand Down
12 changes: 6 additions & 6 deletions program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,8 @@ mod tests {
let mut cache = LoadedPrograms::default();

let program1 = Pubkey::new_unique();
let program1_deployment_slots = vec![0, 10, 20];
let program1_usage_counters = vec![4, 5, 25];
let program1_deployment_slots = [0, 10, 20];
let program1_usage_counters = [4, 5, 25];
program1_deployment_slots
.iter()
.enumerate()
Expand Down Expand Up @@ -891,8 +891,8 @@ mod tests {
}

let program2 = Pubkey::new_unique();
let program2_deployment_slots = vec![5, 11];
let program2_usage_counters = vec![0, 2];
let program2_deployment_slots = [5, 11];
let program2_usage_counters = [0, 2];
program2_deployment_slots
.iter()
.enumerate()
Expand Down Expand Up @@ -924,8 +924,8 @@ mod tests {
}

let program3 = Pubkey::new_unique();
let program3_deployment_slots = vec![0, 5, 15];
let program3_usage_counters = vec![100, 3, 20];
let program3_deployment_slots = [0, 5, 15];
let program3_usage_counters = [100, 3, 20];
program3_deployment_slots
.iter()
.enumerate()
Expand Down
5 changes: 5 additions & 0 deletions sdk/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ pub fn derive_clone_zeroed(input: proc_macro::TokenStream) -> proc_macro::TokenS
let name = &item_struct.ident;
quote! {
impl Clone for #name {
// Clippy lint `incorrect_clone_impl_on_copy_type` requires that clone
// implementations on `Copy` types are simply wrappers of `Copy`.
// This is not the case here, and intentionally so because we want to
// guarantee zeroed padding.
#[allow(clippy::incorrect_clone_impl_on_copy_type)]
fn clone(&self) -> Self {
let mut value = std::mem::MaybeUninit::<Self>::uninit();
unsafe {
Expand Down
6 changes: 3 additions & 3 deletions sdk/program/src/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ mod test {
fn test_bump_allocator() {
// alloc the entire
{
let heap = vec![0u8; 128];
let heap = [0u8; 128];
let allocator = BumpAllocator {
start: heap.as_ptr() as *const _ as usize,
len: heap.len(),
Expand All @@ -398,7 +398,7 @@ mod test {
}
// check alignment
{
let heap = vec![0u8; 128];
let heap = [0u8; 128];
let allocator = BumpAllocator {
start: heap.as_ptr() as *const _ as usize,
len: heap.len(),
Expand All @@ -423,7 +423,7 @@ mod test {
}
// alloc entire block (minus the pos ptr)
{
let heap = vec![0u8; 128];
let heap = [0u8; 128];
let allocator = BumpAllocator {
start: heap.as_ptr() as *const _ as usize,
len: heap.len(),
Expand Down
4 changes: 2 additions & 2 deletions sdk/program/src/message/compiled_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ mod tests {

#[test]
fn test_try_drain_keys_found_in_lookup_table() {
let orig_keys = vec![
let orig_keys = [
Pubkey::new_unique(),
Pubkey::new_unique(),
Pubkey::new_unique(),
Expand Down Expand Up @@ -598,7 +598,7 @@ mod tests {

#[test]
fn test_try_drain_keys_found_in_lookup_table_with_empty_table() {
let original_keys = vec![
let original_keys = [
Pubkey::new_unique(),
Pubkey::new_unique(),
Pubkey::new_unique(),
Expand Down
3 changes: 1 addition & 2 deletions sdk/program/src/sysvar/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ pub struct BorrowedInstruction<'a> {
#[cfg(not(target_os = "solana"))]
bitflags! {
struct InstructionsSysvarAccountMeta: u8 {
const NONE = 0b00000000;
const IS_SIGNER = 0b00000001;
const IS_WRITABLE = 0b00000010;
}
Expand Down Expand Up @@ -126,7 +125,7 @@ fn serialize_instructions(instructions: &[BorrowedInstruction]) -> Vec<u8> {
data[start..start + 2].copy_from_slice(&start_instruction_offset.to_le_bytes());
append_u16(&mut data, instruction.accounts.len() as u16);
for account_meta in &instruction.accounts {
let mut account_meta_flags = InstructionsSysvarAccountMeta::NONE;
let mut account_meta_flags = InstructionsSysvarAccountMeta::empty();
if account_meta.is_signer {
account_meta_flags |= InstructionsSysvarAccountMeta::IS_SIGNER;
}
Expand Down

0 comments on commit a7eda70

Please sign in to comment.