Skip to content

Commit 08adc6b

Browse files
stegaBOBfebo
andauthored
Feat: Add debug/copy derives and enable missing debug/copy lint (#228)
* Add debug/copy derives and enable missing debug/copy lint * Update sdk/pinocchio/src/sysvars/rent.rs Co-authored-by: Fernando Otero <[email protected]> * Update sdk/pinocchio/src/entrypoint/mod.rs Co-authored-by: Fernando Otero <[email protected]> * Update sdk/pinocchio/src/instruction.rs Co-authored-by: Fernando Otero <[email protected]> * Update sdk/pinocchio/src/sysvars/clock.rs Co-authored-by: Fernando Otero <[email protected]> * Update sdk/pinocchio/src/sysvars/fees.rs * Update sdk/pinocchio/src/sysvars/fees.rs * Update sdk/pinocchio/src/sysvars/instructions.rs Co-authored-by: Fernando Otero <[email protected]> * Update sdk/pinocchio/src/sysvars/instructions.rs Co-authored-by: Fernando Otero <[email protected]> * Update sdk/pinocchio/src/sysvars/instructions.rs Co-authored-by: Fernando Otero <[email protected]> * Update sdk/pinocchio/src/sysvars/clock.rs * Fix syntax error in Instructions struct derive macro --------- Co-authored-by: Fernando Otero <[email protected]>
1 parent b96232b commit 08adc6b

File tree

13 files changed

+23
-12
lines changed

13 files changed

+23
-12
lines changed

Cargo.lock

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/pinocchio/src/account_info.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub const MAX_PERMITTED_DATA_INCREASE: usize = 1_024 * 10;
1818

1919
/// Represents masks for borrow state of an account.
2020
#[repr(u8)]
21-
#[derive(Clone, Copy)]
21+
#[derive(Clone, Copy, Debug)]
2222
pub enum BorrowState {
2323
/// Mask to check whether an account is already borrowed.
2424
///
@@ -112,7 +112,7 @@ pub(crate) struct Account {
112112
/// used to track borrows of the account data and lamports, given that an
113113
/// account can be "shared" across multiple `AccountInfo` instances.
114114
#[repr(C)]
115-
#[derive(Clone, PartialEq, Eq)]
115+
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
116116
pub struct AccountInfo {
117117
/// Raw (pointer to) account data.
118118
///
@@ -643,6 +643,7 @@ const LAMPORTS_BORROW_SHIFT: u8 = 4;
643643
const DATA_BORROW_SHIFT: u8 = 0;
644644

645645
/// Reference to account data or lamports with checked borrow rules.
646+
#[derive(Debug)]
646647
pub struct Ref<'a, T: ?Sized> {
647648
value: NonNull<T>,
648649
state: NonNull<u8>,
@@ -714,6 +715,7 @@ const LAMPORTS_MUTABLE_BORROW_BITMASK: u8 = 0b_1000_0000;
714715
const DATA_MUTABLE_BORROW_BITMASK: u8 = 0b_0000_1000;
715716

716717
/// Mutable reference to account data or lamports with checked borrow rules.
718+
#[derive(Debug)]
717719
pub struct RefMut<'a, T: ?Sized> {
718720
value: NonNull<T>,
719721
state: NonNull<u8>,

sdk/pinocchio/src/cpi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ pub fn get_return_data() -> Option<ReturnData> {
515515
}
516516

517517
/// Struct to hold the return data from an invoked program.
518+
#[derive(Debug)]
518519
pub struct ReturnData {
519520
/// Program that most recently set the return data.
520521
program_id: Pubkey,

sdk/pinocchio/src/entrypoint/lazy.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ macro_rules! lazy_program_entrypoint {
100100
///
101101
/// This is a wrapper around the input buffer that provides methods to read the accounts
102102
/// and instruction data. It is used by the lazy entrypoint to access the input data on demand.
103+
#[derive(Debug)]
103104
pub struct InstructionContext {
104105
/// Pointer to the runtime input buffer to read from.
105106
///
@@ -276,6 +277,7 @@ impl InstructionContext {
276277
}
277278

278279
/// Wrapper type around an [`AccountInfo`] that may be a duplicate.
280+
#[derive(Debug, Copy, Clone)]
279281
pub enum MaybeAccount {
280282
/// An [`AccountInfo`] that is not a duplicate.
281283
Account(AccountInfo),

sdk/pinocchio/src/entrypoint/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ mod alloc {
668668

669669
#[cfg(not(feature = "std"))]
670670
/// An allocator that does not allocate memory.
671+
#[derive(Clone, Copy, Debug)]
671672
pub struct NoAllocator;
672673

673674
#[cfg(not(feature = "std"))]

sdk/pinocchio/src/instruction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct ProcessedSiblingInstruction {
3737
/// This struct contains the same information as an [`AccountInfo`], but has
3838
/// the memory layout as expected by `sol_invoke_signed_c` syscall.
3939
#[repr(C)]
40-
#[derive(Clone)]
40+
#[derive(Clone, Copy, Debug)]
4141
pub struct Account<'a> {
4242
// Public key of the account.
4343
key: *const Pubkey,

sdk/pinocchio/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
//! ```ignore
218218
//! cargo build-sbf --features bpf-entrypoint
219219
//! ```
220-
220+
#![warn(missing_copy_implementations, missing_debug_implementations)]
221221
#![no_std]
222222

223223
#[cfg(feature = "std")]

sdk/pinocchio/src/program_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! <https://github.com/anza-xyz/solana-sdk/blob/master/program-error/src/lib.rs>
77
88
/// Reasons the program may fail.
9-
#[derive(Clone, Debug, Eq, PartialEq)]
9+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
1010
pub enum ProgramError {
1111
/// Allows on-chain programs to implement program-specific error types and see them returned
1212
/// by the Solana runtime. A program-specific error may be any type that is represented as

sdk/pinocchio/src/sysvars/clock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub type UnixTimestamp = i64;
3333
///
3434
/// All members of `Clock` start from 0 upon network boot.
3535
#[repr(C)]
36-
#[derive(Copy, Clone)]
36+
#[derive(Clone, Copy, Debug)]
3737
pub struct Clock {
3838
/// The current `Slot`.
3939
pub slot: Slot,

sdk/pinocchio/src/sysvars/fees.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl FeeCalculator {
2222
}
2323

2424
/// Governs the fee rate for the cluster
25-
#[derive(Debug, Clone)]
25+
#[derive(Debug, Clone, Copy)]
2626
pub struct FeeRateGovernor {
2727
/// The current cost of a signature
2828
pub lamports_per_signature: u64,
@@ -74,7 +74,7 @@ impl FeeRateGovernor {
7474
}
7575

7676
/// Fees sysvar
77-
#[derive(Debug)]
77+
#[derive(Copy, Clone, Debug)]
7878
pub struct Fees {
7979
/// Fee calculator for processing transactions
8080
pub fee_calculator: FeeCalculator,

0 commit comments

Comments
 (0)