Skip to content

Commit

Permalink
Merge pull request #76 from kwantam/main
Browse files Browse the repository at this point in the history
fix derive-inside-macro
  • Loading branch information
str4d authored Apr 26, 2022
2 parents e9eb586 + b3041c1 commit dcd0219
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ff_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ num-traits = "0.2"
num-integer = "0.1"
proc-macro2 = "1"
quote = "1"
syn = "1"
syn = { version = "1", features = ["full"] }

[badges]
maintenance = { status = "passively-maintained" }
13 changes: 9 additions & 4 deletions ff_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,16 @@ fn validate_struct(ast: &syn::DeriveInput, limbs: usize) -> Option<proc_macro2::
}

// The array's length should be a literal int equal to `limbs`.
let lit_int = match match &arr.len {
syn::Expr::Lit(expr_lit) => match &expr_lit.lit {
syn::Lit::Int(lit_int) => Some(lit_int),
let expr_lit = match &arr.len {
syn::Expr::Lit(expr_lit) => Some(&expr_lit.lit),
syn::Expr::Group(expr_group) => match &*expr_group.expr {
syn::Expr::Lit(expr_lit) => Some(&expr_lit.lit),
_ => None,
},
}
_ => None
};
let lit_int = match match expr_lit {
Some(syn::Lit::Int(lit_int)) => Some(lit_int),
_ => None,
} {
Some(x) => x,
Expand Down

0 comments on commit dcd0219

Please sign in to comment.