From acc3811158c8042b41405e152cac980516d361db Mon Sep 17 00:00:00 2001 From: Thomas BESSOU Date: Mon, 11 Dec 2023 11:44:06 +0100 Subject: [PATCH] Add support for syn 2.0.40's new Expr::Group to dsl::auto_type This expression may get yielded when parsing `$a: expr` from other macros. --- dsl_auto_type/src/auto_type/expression_type_inference.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dsl_auto_type/src/auto_type/expression_type_inference.rs b/dsl_auto_type/src/auto_type/expression_type_inference.rs index 5e84406ea13d..c42774ed2ef1 100644 --- a/dsl_auto_type/src/auto_type/expression_type_inference.rs +++ b/dsl_auto_type/src/auto_type/expression_type_inference.rs @@ -82,6 +82,9 @@ impl TypeInferrer<'_> { expr, type_hint.filter(|h| !matches!(h, syn::Type::Infer(_))), ) { + (syn::Expr::Group(syn::ExprGroup { expr, .. }), type_hint) => { + return self.try_infer_expression_type(expr, type_hint) + } ( syn::Expr::Tuple(syn::ExprTuple { elems: expr_elems, .. @@ -236,10 +239,10 @@ impl TypeInferrer<'_> { )) } }, - (_, None) => { + (e, None) => { return Err(syn::Error::new( expr.span(), - "unsupported expression for auto_type", + format_args!("unsupported expression for auto_type: {e:?}"), )) } (_, Some(type_hint)) => type_hint.clone(),