Skip to content

Commit 45beb40

Browse files
authored
Fix: realloc and prelude (#3975)
* refactor: replace realloc with resize * refactor: Improve prelude imports with wildcard import
1 parent d4502a6 commit 45beb40

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

lang/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ pub mod prelude {
514514
};
515515
pub use crate::solana_program::account_info::{next_account_info, AccountInfo};
516516
pub use crate::solana_program::instruction::AccountMeta;
517-
pub use crate::solana_program::msg;
518517
pub use crate::solana_program::program_error::ProgramError;
519518
pub use crate::solana_program::pubkey::Pubkey;
520519
pub use crate::solana_program::sysvar::clock::Clock;
@@ -526,6 +525,7 @@ pub mod prelude {
526525
pub use crate::solana_program::sysvar::slot_history::SlotHistory;
527526
pub use crate::solana_program::sysvar::stake_history::StakeHistory;
528527
pub use crate::solana_program::sysvar::Sysvar as SolanaSysvar;
528+
pub use crate::solana_program::*;
529529
pub use anchor_attribute_error::*;
530530
pub use borsh;
531531
pub use error::*;

lang/syn/src/codegen/accounts/constraints.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ fn generate_constraint_realloc(
416416
let account_name = field.to_string();
417417
let new_space = &c.space;
418418
let payer = &c.payer;
419-
let zero = &c.zero;
420419

421420
let mut optional_check_scope = OptionalCheckScope::new_with_field(accs, field);
422421
let payer_optional_check = optional_check_scope.generate_check(payer);
@@ -465,7 +464,7 @@ fn generate_constraint_realloc(
465464
**__field_info.lamports.borrow_mut() = __field_info.lamports().checked_sub(__lamport_amt).unwrap();
466465
}
467466

468-
__field_info.realloc(#new_space, #zero)?;
467+
__field_info.resize(#new_space)?;
469468
__reallocs.insert(#field.key());
470469
}
471470
}

lang/syn/src/codegen/program/idl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub fn idl_accounts_and_functions() -> proc_macro2::TokenStream {
236236
.checked_sub(idl_ref.lamports())
237237
.unwrap(),
238238
)?;
239-
idl_ref.realloc(new_account_space, false)?;
239+
idl_ref.resize(new_account_space)?;
240240
}
241241

242242
Ok(())

0 commit comments

Comments
 (0)