Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lang: Remove the unnecessary clone in to_account_info().clone() #2713

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lang/syn/src/codegen/program/idl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub fn idl_accounts_and_functions() -> proc_macro2::TokenStream {
accounts.system_program.to_account_info(),
anchor_lang::system_program::Transfer {
from: accounts.authority.to_account_info(),
to: accounts.idl.to_account_info().clone(),
to: accounts.idl.to_account_info(),
},
),
new_rent_minimum
Expand Down
12 changes: 6 additions & 6 deletions tests/cashiers-check/programs/cashiers-check/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub mod cashiers_check {
) -> Result<()> {
// Transfer funds to the check.
let cpi_accounts = Transfer {
from: ctx.accounts.from.to_account_info().clone(),
to: ctx.accounts.vault.to_account_info().clone(),
from: ctx.accounts.from.to_account_info(),
to: ctx.accounts.vault.to_account_info(),
authority: ctx.accounts.owner.clone(),
};
let cpi_program = ctx.accounts.token_program.clone();
Expand All @@ -50,8 +50,8 @@ pub mod cashiers_check {
];
let signer = &[&seeds[..]];
let cpi_accounts = Transfer {
from: ctx.accounts.vault.to_account_info().clone(),
to: ctx.accounts.to.to_account_info().clone(),
from: ctx.accounts.vault.to_account_info(),
to: ctx.accounts.to.to_account_info(),
authority: ctx.accounts.check_signer.clone(),
};
let cpi_program = ctx.accounts.token_program.clone();
Expand All @@ -70,8 +70,8 @@ pub mod cashiers_check {
];
let signer = &[&seeds[..]];
let cpi_accounts = Transfer {
from: ctx.accounts.vault.to_account_info().clone(),
to: ctx.accounts.from.to_account_info().clone(),
from: ctx.accounts.vault.to_account_info(),
to: ctx.accounts.from.to_account_info(),
authority: ctx.accounts.check_signer.clone(),
};
let cpi_program = ctx.accounts.token_program.clone();
Expand Down
16 changes: 8 additions & 8 deletions tests/escrow/programs/escrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl<'info> From<&mut InitializeEscrow<'info>>
.initializer_deposit_token_account
.to_account_info()
.clone(),
current_authority: accounts.initializer.to_account_info().clone(),
current_authority: accounts.initializer.to_account_info(),
};
let cpi_program = accounts.token_program.to_account_info();
CpiContext::new(cpi_program, cpi_accounts)
Expand All @@ -207,7 +207,7 @@ impl<'info> From<&mut InitializeEscrow<'info>>
impl<'info> CancelEscrow<'info> {
fn into_set_authority_context(&self) -> CpiContext<'_, '_, '_, 'info, SetAuthority<'info>> {
let cpi_accounts = SetAuthority {
account_or_mint: self.pda_deposit_token_account.to_account_info().clone(),
account_or_mint: self.pda_deposit_token_account.to_account_info(),
current_authority: self.pda_account.clone(),
};
let cpi_program = self.token_program.to_account_info();
Expand All @@ -218,7 +218,7 @@ impl<'info> CancelEscrow<'info> {
impl<'info> Exchange<'info> {
fn into_set_authority_context(&self) -> CpiContext<'_, '_, '_, 'info, SetAuthority<'info>> {
let cpi_accounts = SetAuthority {
account_or_mint: self.pda_deposit_token_account.to_account_info().clone(),
account_or_mint: self.pda_deposit_token_account.to_account_info(),
current_authority: self.pda_account.clone(),
};
let cpi_program = self.receive_token_program.to_account_info();
Expand All @@ -231,9 +231,9 @@ impl<'info> Exchange<'info> {
&self,
) -> CpiContext<'_, '_, '_, 'info, TransferChecked<'info>> {
let cpi_accounts = TransferChecked {
from: self.pda_deposit_token_account.to_account_info().clone(),
mint: self.receive_mint.to_account_info().clone(),
to: self.taker_receive_token_account.to_account_info().clone(),
from: self.pda_deposit_token_account.to_account_info(),
mint: self.receive_mint.to_account_info(),
to: self.taker_receive_token_account.to_account_info(),
authority: self.pda_account.clone(),
};
let cpi_program = self.receive_token_program.to_account_info();
Expand All @@ -246,8 +246,8 @@ impl<'info> Exchange<'info> {
&self,
) -> CpiContext<'_, '_, '_, 'info, TransferChecked<'info>> {
let cpi_accounts = TransferChecked {
from: self.taker_deposit_token_account.to_account_info().clone(),
mint: self.deposit_mint.to_account_info().clone(),
from: self.taker_deposit_token_account.to_account_info(),
mint: self.deposit_mint.to_account_info(),
to: self
.initializer_receive_token_account
.to_account_info()
Expand Down
2 changes: 1 addition & 1 deletion tests/lockup/programs/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ impl<'a, 'b, 'c, 'info> From<&mut DepositLocked<'info>>
let cpi_accounts = Transfer {
from: accounts.vesting_vault.clone(),
to: accounts.member_vault.to_account_info(),
authority: accounts.depositor_authority.to_account_info().clone(),
authority: accounts.depositor_authority.to_account_info(),
};
let cpi_program = accounts.token_program.clone();
CpiContext::new(cpi_program, cpi_accounts)
Expand Down
22 changes: 11 additions & 11 deletions tests/spl/token-proxy/programs/token-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ mod token_proxy {
if let Some(token_program) = &ctx.accounts.token_program {
if let Some(mint) = &ctx.accounts.mint {
let cpi_accounts = TransferChecked {
from: ctx.accounts.from.to_account_info().clone(),
mint: mint.to_account_info().clone(),
to: ctx.accounts.to.to_account_info().clone(),
from: ctx.accounts.from.to_account_info(),
mint: mint.to_account_info(),
to: ctx.accounts.to.to_account_info(),
authority: ctx.accounts.authority.clone(),
};
let cpi_program = token_program.to_account_info();
let cpi_context = CpiContext::new(cpi_program, cpi_accounts);
token_interface::transfer_checked(cpi_context, amount, mint.decimals)
} else {
let cpi_accounts = Transfer {
from: ctx.accounts.from.to_account_info().clone(),
to: ctx.accounts.to.to_account_info().clone(),
from: ctx.accounts.from.to_account_info(),
to: ctx.accounts.to.to_account_info(),
authority: ctx.accounts.authority.clone(),
};
let cpi_program = token_program.to_account_info();
Expand Down Expand Up @@ -208,8 +208,8 @@ impl<'a, 'b, 'c, 'info> From<&mut ProxyTransfer<'info>>
{
fn from(accounts: &mut ProxyTransfer<'info>) -> CpiContext<'a, 'b, 'c, 'info, Transfer<'info>> {
let cpi_accounts = Transfer {
from: accounts.from.to_account_info().clone(),
to: accounts.to.to_account_info().clone(),
from: accounts.from.to_account_info(),
to: accounts.to.to_account_info(),
authority: accounts.authority.clone(),
};
let cpi_program = accounts.token_program.to_account_info();
Expand All @@ -222,8 +222,8 @@ impl<'a, 'b, 'c, 'info> From<&mut ProxyMintTo<'info>>
{
fn from(accounts: &mut ProxyMintTo<'info>) -> CpiContext<'a, 'b, 'c, 'info, MintTo<'info>> {
let cpi_accounts = MintTo {
mint: accounts.mint.to_account_info().clone(),
to: accounts.to.to_account_info().clone(),
mint: accounts.mint.to_account_info(),
to: accounts.to.to_account_info(),
authority: accounts.authority.clone(),
};
let cpi_program = accounts.token_program.to_account_info();
Expand All @@ -234,8 +234,8 @@ impl<'a, 'b, 'c, 'info> From<&mut ProxyMintTo<'info>>
impl<'a, 'b, 'c, 'info> From<&mut ProxyBurn<'info>> for CpiContext<'a, 'b, 'c, 'info, Burn<'info>> {
fn from(accounts: &mut ProxyBurn<'info>) -> CpiContext<'a, 'b, 'c, 'info, Burn<'info>> {
let cpi_accounts = Burn {
mint: accounts.mint.to_account_info().clone(),
from: accounts.from.to_account_info().clone(),
mint: accounts.mint.to_account_info(),
from: accounts.from.to_account_info(),
authority: accounts.authority.clone(),
};
let cpi_program = accounts.token_program.to_account_info();
Expand Down
Loading