recursively look for literal in test macro

This commit is contained in:
Joey de Waal 2024-10-01 19:16:32 +02:00 committed by Austin Bonander
parent 293c55ce89
commit ef039c5d67

View file

@ -244,7 +244,19 @@ fn parse_args(attr_args: AttributeArgs) -> syn::Result<Args> {
));
}
let Expr::Lit(syn::ExprLit { lit, .. }) = value.value else {
fn recurse_lit_lookup(expr: Expr) -> Option<Lit> {
match expr {
Expr::Lit(syn::ExprLit { lit, .. }) => {
return Some(lit);
}
Expr::Group(syn::ExprGroup { expr, .. }) => {
return recurse_lit_lookup(*expr);
}
_ => return None,
}
}
let Some(lit) = recurse_lit_lookup(value.value) else {
return Err(syn::Error::new_spanned(path, "expected string for `false`"));
};