浏览代码

Fix `clippy 1.83.0` (#3414)

* lang: Fix `clippy::needless_lifetimes`

* idl: Fix `clippy::unnecessary_lazy_evaluations`

* lang: Fix `clippy::needless_lifetimes`

* client: Fix `clippy::needless_lifetimes`
acheron 10 月之前
父节点
当前提交
7aae0daa1a

+ 1 - 1
client/src/blocking.rs

@@ -19,7 +19,7 @@ use tokio::{
     sync::RwLock,
 };
 
-impl<'a> EventUnsubscriber<'a> {
+impl EventUnsubscriber<'_> {
     /// Unsubscribe gracefully.
     pub fn unsubscribe(self) {
         self.runtime_handle.block_on(self.unsubscribe_internal())

+ 1 - 1
client/src/lib.rs

@@ -497,7 +497,7 @@ pub trait AsSigner {
     fn as_signer(&self) -> &dyn Signer;
 }
 
-impl<'a> AsSigner for Box<dyn Signer + 'a> {
+impl AsSigner for Box<dyn Signer + '_> {
     fn as_signer(&self) -> &dyn Signer {
         self.as_ref()
     }

+ 1 - 1
idl/src/convert.rs

@@ -431,7 +431,7 @@ mod legacy {
         fn from(value: IdlTypeDefinitionTy) -> Self {
             match value {
                 IdlTypeDefinitionTy::Struct { fields } => Self::Struct {
-                    fields: fields.is_empty().then(|| None).unwrap_or_else(|| {
+                    fields: fields.is_empty().then_some(None).unwrap_or_else(|| {
                         Some(t::IdlDefinedFields::Named(
                             fields.into_iter().map(Into::into).collect(),
                         ))

+ 7 - 9
lang/src/accounts/account.rs

@@ -229,15 +229,13 @@ pub struct Account<'info, T: AccountSerialize + AccountDeserialize + Clone> {
     info: &'info AccountInfo<'info>,
 }
 
-impl<'info, T: AccountSerialize + AccountDeserialize + Clone + fmt::Debug> fmt::Debug
-    for Account<'info, T>
-{
+impl<T: AccountSerialize + AccountDeserialize + Clone + fmt::Debug> fmt::Debug for Account<'_, T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         self.fmt_with_name("Account", f)
     }
 }
 
-impl<'info, T: AccountSerialize + AccountDeserialize + Clone + fmt::Debug> Account<'info, T> {
+impl<T: AccountSerialize + AccountDeserialize + Clone + fmt::Debug> Account<'_, T> {
     pub(crate) fn fmt_with_name(&self, name: &str, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_struct(name)
             .field("account", &self.account)
@@ -369,7 +367,7 @@ impl<'info, T: AccountSerialize + AccountDeserialize + Clone> AccountsClose<'inf
     }
 }
 
-impl<'info, T: AccountSerialize + AccountDeserialize + Clone> ToAccountMetas for Account<'info, T> {
+impl<T: AccountSerialize + AccountDeserialize + Clone> ToAccountMetas for Account<'_, T> {
     fn to_account_metas(&self, is_signer: Option<bool>) -> Vec<AccountMeta> {
         let is_signer = is_signer.unwrap_or(self.info.is_signer);
         let meta = match self.info.is_writable {
@@ -396,13 +394,13 @@ impl<'info, T: AccountSerialize + AccountDeserialize + Clone> AsRef<AccountInfo<
     }
 }
 
-impl<'info, T: AccountSerialize + AccountDeserialize + Clone> AsRef<T> for Account<'info, T> {
+impl<T: AccountSerialize + AccountDeserialize + Clone> AsRef<T> for Account<'_, T> {
     fn as_ref(&self) -> &T {
         &self.account
     }
 }
 
-impl<'a, T: AccountSerialize + AccountDeserialize + Clone> Deref for Account<'a, T> {
+impl<T: AccountSerialize + AccountDeserialize + Clone> Deref for Account<'_, T> {
     type Target = T;
 
     fn deref(&self) -> &Self::Target {
@@ -410,7 +408,7 @@ impl<'a, T: AccountSerialize + AccountDeserialize + Clone> Deref for Account<'a,
     }
 }
 
-impl<'a, T: AccountSerialize + AccountDeserialize + Clone> DerefMut for Account<'a, T> {
+impl<T: AccountSerialize + AccountDeserialize + Clone> DerefMut for Account<'_, T> {
     fn deref_mut(&mut self) -> &mut Self::Target {
         #[cfg(feature = "anchor-debug")]
         if !self.info.is_writable {
@@ -421,7 +419,7 @@ impl<'a, T: AccountSerialize + AccountDeserialize + Clone> DerefMut for Account<
     }
 }
 
-impl<'info, T: AccountSerialize + AccountDeserialize + Clone> Key for Account<'info, T> {
+impl<T: AccountSerialize + AccountDeserialize + Clone> Key for Account<'_, T> {
     fn key(&self) -> Pubkey {
         *self.info.key
     }

+ 2 - 2
lang/src/accounts/account_info.rs

@@ -26,7 +26,7 @@ impl<'info, B> Accounts<'info, B> for AccountInfo<'info> {
     }
 }
 
-impl<'info> ToAccountMetas for AccountInfo<'info> {
+impl ToAccountMetas for AccountInfo<'_> {
     fn to_account_metas(&self, is_signer: Option<bool>) -> Vec<AccountMeta> {
         let is_signer = is_signer.unwrap_or(self.is_signer);
         let meta = match self.is_writable {
@@ -45,7 +45,7 @@ impl<'info> ToAccountInfos<'info> for AccountInfo<'info> {
 
 impl<'info> AccountsExit<'info> for AccountInfo<'info> {}
 
-impl<'info> Key for AccountInfo<'info> {
+impl Key for AccountInfo<'_> {
     fn key(&self) -> Pubkey {
         *self.key
     }

+ 3 - 3
lang/src/accounts/account_loader.rs

@@ -98,7 +98,7 @@ pub struct AccountLoader<'info, T: ZeroCopy + Owner> {
     phantom: PhantomData<&'info T>,
 }
 
-impl<'info, T: ZeroCopy + Owner + fmt::Debug> fmt::Debug for AccountLoader<'info, T> {
+impl<T: ZeroCopy + Owner + fmt::Debug> fmt::Debug for AccountLoader<'_, T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_struct("AccountLoader")
             .field("acc_info", &self.acc_info)
@@ -260,7 +260,7 @@ impl<'info, T: ZeroCopy + Owner> AccountsClose<'info> for AccountLoader<'info, T
     }
 }
 
-impl<'info, T: ZeroCopy + Owner> ToAccountMetas for AccountLoader<'info, T> {
+impl<T: ZeroCopy + Owner> ToAccountMetas for AccountLoader<'_, T> {
     fn to_account_metas(&self, is_signer: Option<bool>) -> Vec<AccountMeta> {
         let is_signer = is_signer.unwrap_or(self.acc_info.is_signer);
         let meta = match self.acc_info.is_writable {
@@ -283,7 +283,7 @@ impl<'info, T: ZeroCopy + Owner> ToAccountInfos<'info> for AccountLoader<'info,
     }
 }
 
-impl<'info, T: ZeroCopy + Owner> Key for AccountLoader<'info, T> {
+impl<T: ZeroCopy + Owner> Key for AccountLoader<'_, T> {
     fn key(&self) -> Pubkey {
         *self.acc_info.key
     }

+ 2 - 2
lang/src/accounts/interface.rs

@@ -123,7 +123,7 @@ impl<'info, B, T: CheckId> Accounts<'info, B> for Interface<'info, T> {
     }
 }
 
-impl<'info, T> ToAccountMetas for Interface<'info, T> {
+impl<T> ToAccountMetas for Interface<'_, T> {
     fn to_account_metas(&self, is_signer: Option<bool>) -> Vec<AccountMeta> {
         self.0.to_account_metas(is_signer)
     }
@@ -137,7 +137,7 @@ impl<'info, T> ToAccountInfos<'info> for Interface<'info, T> {
 
 impl<'info, T: AccountDeserialize> AccountsExit<'info> for Interface<'info, T> {}
 
-impl<'info, T: AccountDeserialize> Key for Interface<'info, T> {
+impl<T: AccountDeserialize> Key for Interface<'_, T> {
     fn key(&self) -> Pubkey {
         self.0.key()
     }

+ 7 - 11
lang/src/accounts/interface_account.rs

@@ -165,8 +165,8 @@ pub struct InterfaceAccount<'info, T: AccountSerialize + AccountDeserialize + Cl
     owner: Pubkey,
 }
 
-impl<'info, T: AccountSerialize + AccountDeserialize + Clone + fmt::Debug> fmt::Debug
-    for InterfaceAccount<'info, T>
+impl<T: AccountSerialize + AccountDeserialize + Clone + fmt::Debug> fmt::Debug
+    for InterfaceAccount<'_, T>
 {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         self.account.fmt_with_name("InterfaceAccount", f)
@@ -276,9 +276,7 @@ impl<'info, T: AccountSerialize + AccountDeserialize + Clone> AccountsClose<'inf
     }
 }
 
-impl<'info, T: AccountSerialize + AccountDeserialize + Clone> ToAccountMetas
-    for InterfaceAccount<'info, T>
-{
+impl<T: AccountSerialize + AccountDeserialize + Clone> ToAccountMetas for InterfaceAccount<'_, T> {
     fn to_account_metas(&self, is_signer: Option<bool>) -> Vec<AccountMeta> {
         self.account.to_account_metas(is_signer)
     }
@@ -300,15 +298,13 @@ impl<'info, T: AccountSerialize + AccountDeserialize + Clone> AsRef<AccountInfo<
     }
 }
 
-impl<'info, T: AccountSerialize + AccountDeserialize + Clone> AsRef<T>
-    for InterfaceAccount<'info, T>
-{
+impl<T: AccountSerialize + AccountDeserialize + Clone> AsRef<T> for InterfaceAccount<'_, T> {
     fn as_ref(&self) -> &T {
         self.account.as_ref()
     }
 }
 
-impl<'a, T: AccountSerialize + AccountDeserialize + Clone> Deref for InterfaceAccount<'a, T> {
+impl<T: AccountSerialize + AccountDeserialize + Clone> Deref for InterfaceAccount<'_, T> {
     type Target = T;
 
     fn deref(&self) -> &Self::Target {
@@ -316,13 +312,13 @@ impl<'a, T: AccountSerialize + AccountDeserialize + Clone> Deref for InterfaceAc
     }
 }
 
-impl<'a, T: AccountSerialize + AccountDeserialize + Clone> DerefMut for InterfaceAccount<'a, T> {
+impl<T: AccountSerialize + AccountDeserialize + Clone> DerefMut for InterfaceAccount<'_, T> {
     fn deref_mut(&mut self) -> &mut Self::Target {
         self.account.deref_mut()
     }
 }
 
-impl<'info, T: AccountSerialize + AccountDeserialize + Clone> Key for InterfaceAccount<'info, T> {
+impl<T: AccountSerialize + AccountDeserialize + Clone> Key for InterfaceAccount<'_, T> {
     fn key(&self) -> Pubkey {
         self.account.key()
     }

+ 3 - 3
lang/src/accounts/lazy_account.rs

@@ -185,7 +185,7 @@ where
     pub __fields: Rc<RefCell<Option<Vec<bool>>>>,
 }
 
-impl<'info, T> fmt::Debug for LazyAccount<'info, T>
+impl<T> fmt::Debug for LazyAccount<'_, T>
 where
     T: AccountSerialize + Discriminator + Owner + Clone + fmt::Debug,
 {
@@ -296,7 +296,7 @@ where
     }
 }
 
-impl<'info, T> ToAccountMetas for LazyAccount<'info, T>
+impl<T> ToAccountMetas for LazyAccount<'_, T>
 where
     T: AccountSerialize + Discriminator + Owner + Clone,
 {
@@ -328,7 +328,7 @@ where
     }
 }
 
-impl<'info, T> Key for LazyAccount<'info, T>
+impl<T> Key for LazyAccount<'_, T>
 where
     T: AccountSerialize + Discriminator + Owner + Clone,
 {

+ 3 - 3
lang/src/accounts/program.rs

@@ -80,7 +80,7 @@ pub struct Program<'info, T> {
     _phantom: PhantomData<T>,
 }
 
-impl<'info, T: fmt::Debug> fmt::Debug for Program<'info, T> {
+impl<T: fmt::Debug> fmt::Debug for Program<'_, T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_struct("Program").field("info", &self.info).finish()
     }
@@ -157,7 +157,7 @@ impl<'info, B, T: Id> Accounts<'info, B> for Program<'info, T> {
     }
 }
 
-impl<'info, T> ToAccountMetas for Program<'info, T> {
+impl<T> ToAccountMetas for Program<'_, T> {
     fn to_account_metas(&self, is_signer: Option<bool>) -> Vec<AccountMeta> {
         let is_signer = is_signer.unwrap_or(self.info.is_signer);
         let meta = match self.info.is_writable {
@@ -190,7 +190,7 @@ impl<'info, T> Deref for Program<'info, T> {
 
 impl<'info, T: AccountDeserialize> AccountsExit<'info> for Program<'info, T> {}
 
-impl<'info, T: AccountDeserialize> Key for Program<'info, T> {
+impl<T: AccountDeserialize> Key for Program<'_, T> {
     fn key(&self) -> Pubkey {
         *self.info.key
     }

+ 2 - 2
lang/src/accounts/signer.rs

@@ -74,7 +74,7 @@ impl<'info, B> Accounts<'info, B> for Signer<'info> {
 
 impl<'info> AccountsExit<'info> for Signer<'info> {}
 
-impl<'info> ToAccountMetas for Signer<'info> {
+impl ToAccountMetas for Signer<'_> {
     fn to_account_metas(&self, is_signer: Option<bool>) -> Vec<AccountMeta> {
         let is_signer = is_signer.unwrap_or(self.info.is_signer);
         let meta = match self.info.is_writable {
@@ -105,7 +105,7 @@ impl<'info> Deref for Signer<'info> {
     }
 }
 
-impl<'info> Key for Signer<'info> {
+impl Key for Signer<'_> {
     fn key(&self) -> Pubkey {
         *self.info.key
     }

+ 2 - 2
lang/src/accounts/system_account.rs

@@ -49,7 +49,7 @@ impl<'info, B> Accounts<'info, B> for SystemAccount<'info> {
 
 impl<'info> AccountsExit<'info> for SystemAccount<'info> {}
 
-impl<'info> ToAccountMetas for SystemAccount<'info> {
+impl ToAccountMetas for SystemAccount<'_> {
     fn to_account_metas(&self, is_signer: Option<bool>) -> Vec<AccountMeta> {
         let is_signer = is_signer.unwrap_or(self.info.is_signer);
         let meta = match self.info.is_writable {
@@ -80,7 +80,7 @@ impl<'info> Deref for SystemAccount<'info> {
     }
 }
 
-impl<'info> Key for SystemAccount<'info> {
+impl Key for SystemAccount<'_> {
     fn key(&self) -> Pubkey {
         *self.info.key
     }

+ 6 - 6
lang/src/accounts/sysvar.rs

@@ -35,7 +35,7 @@ pub struct Sysvar<'info, T: solana_program::sysvar::Sysvar> {
     account: T,
 }
 
-impl<'info, T: solana_program::sysvar::Sysvar + fmt::Debug> fmt::Debug for Sysvar<'info, T> {
+impl<T: solana_program::sysvar::Sysvar + fmt::Debug> fmt::Debug for Sysvar<'_, T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_struct("Sysvar")
             .field("info", &self.info)
@@ -56,7 +56,7 @@ impl<'info, T: solana_program::sysvar::Sysvar> Sysvar<'info, T> {
     }
 }
 
-impl<'info, T: solana_program::sysvar::Sysvar> Clone for Sysvar<'info, T> {
+impl<T: solana_program::sysvar::Sysvar> Clone for Sysvar<'_, T> {
     fn clone(&self) -> Self {
         Self {
             info: self.info,
@@ -82,7 +82,7 @@ impl<'info, B, T: solana_program::sysvar::Sysvar> Accounts<'info, B> for Sysvar<
     }
 }
 
-impl<'info, T: solana_program::sysvar::Sysvar> ToAccountMetas for Sysvar<'info, T> {
+impl<T: solana_program::sysvar::Sysvar> ToAccountMetas for Sysvar<'_, T> {
     fn to_account_metas(&self, _is_signer: Option<bool>) -> Vec<AccountMeta> {
         vec![AccountMeta::new_readonly(*self.info.key, false)]
     }
@@ -100,7 +100,7 @@ impl<'info, T: solana_program::sysvar::Sysvar> AsRef<AccountInfo<'info>> for Sys
     }
 }
 
-impl<'a, T: solana_program::sysvar::Sysvar> Deref for Sysvar<'a, T> {
+impl<T: solana_program::sysvar::Sysvar> Deref for Sysvar<'_, T> {
     type Target = T;
 
     fn deref(&self) -> &Self::Target {
@@ -108,7 +108,7 @@ impl<'a, T: solana_program::sysvar::Sysvar> Deref for Sysvar<'a, T> {
     }
 }
 
-impl<'a, T: solana_program::sysvar::Sysvar> DerefMut for Sysvar<'a, T> {
+impl<T: solana_program::sysvar::Sysvar> DerefMut for Sysvar<'_, T> {
     fn deref_mut(&mut self) -> &mut Self::Target {
         &mut self.account
     }
@@ -116,7 +116,7 @@ impl<'a, T: solana_program::sysvar::Sysvar> DerefMut for Sysvar<'a, T> {
 
 impl<'info, T: solana_program::sysvar::Sysvar> AccountsExit<'info> for Sysvar<'info, T> {}
 
-impl<'info, T: solana_program::sysvar::Sysvar> Key for Sysvar<'info, T> {
+impl<T: solana_program::sysvar::Sysvar> Key for Sysvar<'_, T> {
     fn key(&self) -> Pubkey {
         *self.info.key
     }

+ 2 - 2
lang/src/accounts/unchecked_account.rs

@@ -37,7 +37,7 @@ impl<'info, B> Accounts<'info, B> for UncheckedAccount<'info> {
     }
 }
 
-impl<'info> ToAccountMetas for UncheckedAccount<'info> {
+impl ToAccountMetas for UncheckedAccount<'_> {
     fn to_account_metas(&self, is_signer: Option<bool>) -> Vec<AccountMeta> {
         let is_signer = is_signer.unwrap_or(self.is_signer);
         let meta = match self.is_writable {
@@ -70,7 +70,7 @@ impl<'info> Deref for UncheckedAccount<'info> {
     }
 }
 
-impl<'info> Key for UncheckedAccount<'info> {
+impl Key for UncheckedAccount<'_> {
     fn key(&self) -> Pubkey {
         *self.0.key
     }

+ 1 - 1
lang/src/context.rs

@@ -36,7 +36,7 @@ pub struct Context<'a, 'b, 'c, 'info, T: Bumps> {
     pub bumps: T::Bumps,
 }
 
-impl<'a, 'b, 'c, 'info, T> fmt::Debug for Context<'a, 'b, 'c, 'info, T>
+impl<T> fmt::Debug for Context<'_, '_, '_, '_, T>
 where
     T: fmt::Debug + Bumps,
 {

+ 1 - 1
lang/syn/src/parser/context.rs

@@ -94,7 +94,7 @@ pub struct ModuleContext<'krate> {
     detail: &'krate ParsedModule,
 }
 
-impl<'krate> ModuleContext<'krate> {
+impl ModuleContext<'_> {
     pub fn items(&self) -> impl Iterator<Item = &syn::Item> {
         self.detail.items.iter()
     }