febo / pinocchio

Create Solana programs with no dependencies attached
Apache License 2.0
92 stars 19 forks source link

Fix entrypoint compile error trait bound `AccountInfo: Copy` is not satisfied #6

Closed billythedummy closed 2 months ago

billythedummy commented 2 months ago

Seems like MaybeUninit has changed in newer vers of rustc (using 1.81.0). Error msg pasted below for reference:

error[E0277]: the trait bound `AccountInfo: Copy` is not satisfied
 --> program/src/lib.rs:3:1
  |
3 | entrypoint!(process_instruction);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `AccountInfo`, which is required by `MaybeUninit<AccountInfo>: Copy`
  |
  = note: required for `MaybeUninit<AccountInfo>` to implement `Copy`
  = note: the `Copy` trait is required because this value will be copied for each element of the array
  = note: this error originates in the macro `entrypoint` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position
 --> /home/user/.cargo/git/checkouts/pinocchio-545b06e1308f21f1/bbfe860/sdk/src/entrypoint.rs:113:13
  |
11~             const ARRAY_REPEAT_VALUE: MaybeUninit<AccountInfo> = std::mem::MaybeUninit::<$crate::account_info::AccountInfo>::uninit();
11~             let mut accounts =
11~                 [ARRAY_REPEAT_VALUE; $maximum];