Browse Source

lang: fix clippy (#1164)

Paul 3 years ago
parent
commit
8aab5b4634
3 changed files with 14 additions and 2 deletions
  1. 1 2
      cli/src/lib.rs
  2. 9 0
      client/src/lib.rs
  3. 4 0
      lang/src/context.rs

+ 1 - 2
cli/src/lib.rs

@@ -1265,8 +1265,7 @@ fn fetch_idl(cfg_override: &ConfigOverride, idl_addr: Pubkey) -> Result<Idl> {
 
 
 fn extract_idl(file: &str) -> Result<Option<Idl>> {
 fn extract_idl(file: &str) -> Result<Option<Idl>> {
     let file = shellexpand::tilde(file);
     let file = shellexpand::tilde(file);
-    let manifest_from_path =
-        std::env::current_dir()?.join(PathBuf::from(&*file).parent().unwrap().to_path_buf());
+    let manifest_from_path = std::env::current_dir()?.join(PathBuf::from(&*file).parent().unwrap());
     let cargo = Manifest::discover_from_path(manifest_from_path)?
     let cargo = Manifest::discover_from_path(manifest_from_path)?
         .ok_or_else(|| anyhow!("Cargo.toml not found"))?;
         .ok_or_else(|| anyhow!("Cargo.toml not found"))?;
     anchor_syn::idl::file::parse(&*file, cargo.version())
     anchor_syn::idl::file::parse(&*file, cargo.version())

+ 9 - 0
client/src/lib.rs

@@ -362,37 +362,44 @@ impl<'a> RequestBuilder<'a> {
         }
         }
     }
     }
 
 
+    #[must_use]
     pub fn payer(mut self, payer: Keypair) -> Self {
     pub fn payer(mut self, payer: Keypair) -> Self {
         self.payer = payer;
         self.payer = payer;
         self
         self
     }
     }
 
 
+    #[must_use]
     pub fn cluster(mut self, url: &str) -> Self {
     pub fn cluster(mut self, url: &str) -> Self {
         self.cluster = url.to_string();
         self.cluster = url.to_string();
         self
         self
     }
     }
 
 
+    #[must_use]
     pub fn instruction(mut self, ix: Instruction) -> Self {
     pub fn instruction(mut self, ix: Instruction) -> Self {
         self.instructions.push(ix);
         self.instructions.push(ix);
         self
         self
     }
     }
 
 
+    #[must_use]
     pub fn program(mut self, program_id: Pubkey) -> Self {
     pub fn program(mut self, program_id: Pubkey) -> Self {
         self.program_id = program_id;
         self.program_id = program_id;
         self
         self
     }
     }
 
 
+    #[must_use]
     pub fn accounts(mut self, accounts: impl ToAccountMetas) -> Self {
     pub fn accounts(mut self, accounts: impl ToAccountMetas) -> Self {
         let mut metas = accounts.to_account_metas(None);
         let mut metas = accounts.to_account_metas(None);
         self.accounts.append(&mut metas);
         self.accounts.append(&mut metas);
         self
         self
     }
     }
 
 
+    #[must_use]
     pub fn options(mut self, options: CommitmentConfig) -> Self {
     pub fn options(mut self, options: CommitmentConfig) -> Self {
         self.options = options;
         self.options = options;
         self
         self
     }
     }
 
 
+    #[must_use]
     pub fn args(mut self, args: impl InstructionData) -> Self {
     pub fn args(mut self, args: impl InstructionData) -> Self {
         self.instruction_data = Some(args.data());
         self.instruction_data = Some(args.data());
         self
         self
@@ -400,6 +407,7 @@ impl<'a> RequestBuilder<'a> {
 
 
     /// Invokes the `#[state]`'s `new` constructor.
     /// Invokes the `#[state]`'s `new` constructor.
     #[allow(clippy::wrong_self_convention)]
     #[allow(clippy::wrong_self_convention)]
+    #[must_use]
     pub fn new(mut self, args: impl InstructionData) -> Self {
     pub fn new(mut self, args: impl InstructionData) -> Self {
         assert!(self.namespace == RequestNamespace::State { new: false });
         assert!(self.namespace == RequestNamespace::State { new: false });
         self.namespace = RequestNamespace::State { new: true };
         self.namespace = RequestNamespace::State { new: true };
@@ -407,6 +415,7 @@ impl<'a> RequestBuilder<'a> {
         self
         self
     }
     }
 
 
+    #[must_use]
     pub fn signer(mut self, signer: &'a dyn Signer) -> Self {
     pub fn signer(mut self, signer: &'a dyn Signer) -> Self {
         self.signers.push(signer);
         self.signers.push(signer);
         self
         self

+ 4 - 0
lang/src/context.rs

@@ -63,6 +63,7 @@ where
         }
         }
     }
     }
 
 
+    #[must_use]
     pub fn new_with_signer(
     pub fn new_with_signer(
         program: AccountInfo<'info>,
         program: AccountInfo<'info>,
         accounts: T,
         accounts: T,
@@ -76,11 +77,13 @@ where
         }
         }
     }
     }
 
 
+    #[must_use]
     pub fn with_signer(mut self, signer_seeds: &'a [&'b [&'c [u8]]]) -> Self {
     pub fn with_signer(mut self, signer_seeds: &'a [&'b [&'c [u8]]]) -> Self {
         self.signer_seeds = signer_seeds;
         self.signer_seeds = signer_seeds;
         self
         self
     }
     }
 
 
+    #[must_use]
     pub fn with_remaining_accounts(mut self, ra: Vec<AccountInfo<'info>>) -> Self {
     pub fn with_remaining_accounts(mut self, ra: Vec<AccountInfo<'info>>) -> Self {
         self.remaining_accounts = ra;
         self.remaining_accounts = ra;
         self
         self
@@ -156,6 +159,7 @@ impl<'a, 'b, 'c, 'info, T: Accounts<'info>> CpiStateContext<'a, 'b, 'c, 'info, T
         }
         }
     }
     }
 
 
+    #[must_use]
     pub fn with_signer(mut self, signer_seeds: &'a [&'b [&'c [u8]]]) -> Self {
     pub fn with_signer(mut self, signer_seeds: &'a [&'b [&'c [u8]]]) -> Self {
         self.cpi_ctx = self.cpi_ctx.with_signer(signer_seeds);
         self.cpi_ctx = self.cpi_ctx.with_signer(signer_seeds);
         self
         self