Check for None-delimited group in attribute value

This commit is contained in:
David Tolnay 2023-03-20 04:03:25 -07:00
parent c3d637f397
commit dd460f82a1
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 21 additions and 16 deletions

View File

@ -24,7 +24,7 @@ proc-macro = true
[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
syn = "2.0"
syn = "2.0.3"
[dev-dependencies]
serde = { version = "1.0", path = "../serde" }

View File

@ -1381,12 +1381,18 @@ fn get_lit_str2(
meta_item_name: Symbol,
meta: &ParseNestedMeta,
) -> syn::Result<Option<syn::LitStr>> {
match meta.value()?.parse()? {
syn::Expr::Lit(syn::ExprLit {
let expr: syn::Expr = meta.value()?.parse()?;
let mut value = &expr;
while let syn::Expr::Group(e) = value {
value = &e.expr;
}
if let syn::Expr::Lit(syn::ExprLit {
lit: syn::Lit::Str(lit),
..
}) => Ok(Some(lit)),
expr => {
}) = value
{
Ok(Some(lit.clone()))
} else {
cx.error_spanned_by(
expr,
format!(
@ -1396,7 +1402,6 @@ fn get_lit_str2(
);
Ok(None)
}
}
}
fn parse_lit_into_path(