瀏覽代碼

lang: Fix `align` repr support in `declare-program!` (#3056)

Co-authored-by: acheron <98934430+acheroncrypto@users.noreply.github.com>
Burbo 1 年之前
父節點
當前提交
e68b96f454
共有 2 個文件被更改,包括 3 次插入0 次删除
  1. 1 0
      CHANGELOG.md
  2. 2 0
      lang/attribute/program/src/declare_program/common.rs

+ 1 - 0
CHANGELOG.md

@@ -20,6 +20,7 @@ The minor version will be incremented upon a breaking change and the patch versi
 
 - idl: Make safety comment checks fail silently when program path env is not set ([#3045](https://github.com/coral-xyz/anchor/pull/3045)).
 - idl: Avoid interference from rust tests during IDL generation ([#3058](https://github.com/coral-xyz/anchor/pull/3058)).
+- lang: Fix `align` repr support in `declare-program!` ([#3056](https://github.com/coral-xyz/anchor/pull/3056)).
 
 ### Breaking
 

+ 2 - 0
lang/attribute/program/src/declare_program/common.rs

@@ -2,6 +2,7 @@ use anchor_lang_idl::types::{
     Idl, IdlArrayLen, IdlDefinedFields, IdlField, IdlGenericArg, IdlRepr, IdlSerialization,
     IdlType, IdlTypeDef, IdlTypeDefGeneric, IdlTypeDefTy,
 };
+use proc_macro2::Literal;
 use quote::{format_ident, quote};
 
 /// This function should ideally return the absolute path to the declared program's id but because
@@ -168,6 +169,7 @@ pub fn convert_idl_type_def_to_ts(
                 let packed = modifier.packed.then(|| quote!(packed)).unwrap_or_default();
                 let align = modifier
                     .align
+                    .map(Literal::usize_unsuffixed)
                     .map(|align| quote!(align(#align)))
                     .unwrap_or_default();