Skip to content

Commit ef039c5

Browse files
joeydewaalabonander
authored andcommitted
recursively look for literal in test macro
1 parent 293c55c commit ef039c5

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

sqlx-macros-core/src/test_attr.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,19 @@ fn parse_args(attr_args: AttributeArgs) -> syn::Result<Args> {
244244
));
245245
}
246246

247-
let Expr::Lit(syn::ExprLit { lit, .. }) = value.value else {
247+
fn recurse_lit_lookup(expr: Expr) -> Option<Lit> {
248+
match expr {
249+
Expr::Lit(syn::ExprLit { lit, .. }) => {
250+
return Some(lit);
251+
}
252+
Expr::Group(syn::ExprGroup { expr, .. }) => {
253+
return recurse_lit_lookup(*expr);
254+
}
255+
_ => return None,
256+
}
257+
}
258+
259+
let Some(lit) = recurse_lit_lookup(value.value) else {
248260
return Err(syn::Error::new_spanned(path, "expected string for `false`"));
249261
};
250262

0 commit comments

Comments
 (0)