Browse Source

lang: Remove not required `to_account_info()` call (#914)

Kirill Fomichev 4 years ago
parent
commit
6a19cc48ef

+ 3 - 3
lang/src/program.rs

@@ -9,13 +9,13 @@ use std::ops::Deref;
 /// Account container that checks ownership on deserialization.
 /// Account container that checks ownership on deserialization.
 #[derive(Clone)]
 #[derive(Clone)]
 pub struct Program<'info, T: Id + AccountDeserialize + Clone> {
 pub struct Program<'info, T: Id + AccountDeserialize + Clone> {
-    account: T,
+    _account: T,
     info: AccountInfo<'info>,
     info: AccountInfo<'info>,
 }
 }
 
 
 impl<'a, T: Id + AccountDeserialize + Clone> Program<'a, T> {
 impl<'a, T: Id + AccountDeserialize + Clone> Program<'a, T> {
-    fn new(info: AccountInfo<'a>, account: T) -> Program<'a, T> {
-        Self { info, account }
+    fn new(info: AccountInfo<'a>, _account: T) -> Program<'a, T> {
+        Self { info, _account }
     }
     }
 
 
     /// Deserializes the given `info` into a `Program`.
     /// Deserializes the given `info` into a `Program`.

+ 0 - 1
lang/src/vec.rs

@@ -34,7 +34,6 @@ impl<'info, T: Accounts<'info>> Accounts<'info> for Vec<T> {
 
 
 #[cfg(test)]
 #[cfg(test)]
 mod tests {
 mod tests {
-    use crate::ToAccountInfo;
     use solana_program::clock::Epoch;
     use solana_program::clock::Epoch;
     use solana_program::pubkey::Pubkey;
     use solana_program::pubkey::Pubkey;
 
 

+ 1 - 1
lang/syn/src/codegen/accounts/constraints.rs

@@ -209,7 +209,7 @@ pub fn generate_constraint_signer(f: &Field, _c: &ConstraintSigner) -> proc_macr
         _ => panic!("Invalid syntax: signer cannot be specified."),
         _ => panic!("Invalid syntax: signer cannot be specified."),
     };
     };
     quote! {
     quote! {
-        if !#info.to_account_info().is_signer {
+        if !#info.is_signer {
             return Err(anchor_lang::__private::ErrorCode::ConstraintSigner.into());
             return Err(anchor_lang::__private::ErrorCode::ConstraintSigner.into());
         }
         }
     }
     }

+ 1 - 3
lang/syn/src/parser/error.rs

@@ -46,9 +46,7 @@ fn parse_error_attribute(variant: &syn::Variant) -> Option<String> {
         1 => {
         1 => {
             let attr = &attrs[0];
             let attr = &attrs[0];
             let attr_str = attr.path.segments[0].ident.to_string();
             let attr_str = attr.path.segments[0].ident.to_string();
-            if &attr_str != "msg" {
-                panic!("Use msg to specify error strings");
-            }
+            assert!(&attr_str == "msg", "Use msg to specify error strings");
 
 
             let mut tts = attr.tokens.clone().into_iter();
             let mut tts = attr.tokens.clone().into_iter();
             let g_stream = match tts.next().expect("Must have a token group") {
             let g_stream = match tts.next().expect("Must have a token group") {