Browse Source

lang: Fix compilation error when an `#[account]` struct has generics (#3148)

acheron 1 year ago
parent
commit
4853cd1da7
1 changed files with 5 additions and 1 deletions
  1. 5 1
      lang/attribute/account/src/lib.rs

+ 5 - 1
lang/attribute/account/src/lib.rs

@@ -100,7 +100,11 @@ pub fn account(
         );
         format!("{discriminator:?}").parse().unwrap()
     };
-    let disc = quote! { #account_name::DISCRIMINATOR };
+    let disc = if account_strct.generics.lt_token.is_some() {
+        quote! { #account_name::#type_gen::DISCRIMINATOR }
+    } else {
+        quote! { #account_name::DISCRIMINATOR }
+    };
 
     let owner_impl = {
         if namespace.is_empty() {