Check for None-delimited group in attribute value
This commit is contained in:
parent
c3d637f397
commit
dd460f82a1
@ -24,7 +24,7 @@ proc-macro = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = "2.0"
|
syn = "2.0.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde = { version = "1.0", path = "../serde" }
|
serde = { version = "1.0", path = "../serde" }
|
||||||
|
@ -1381,21 +1381,26 @@ fn get_lit_str2(
|
|||||||
meta_item_name: Symbol,
|
meta_item_name: Symbol,
|
||||||
meta: &ParseNestedMeta,
|
meta: &ParseNestedMeta,
|
||||||
) -> syn::Result<Option<syn::LitStr>> {
|
) -> syn::Result<Option<syn::LitStr>> {
|
||||||
match meta.value()?.parse()? {
|
let expr: syn::Expr = meta.value()?.parse()?;
|
||||||
syn::Expr::Lit(syn::ExprLit {
|
let mut value = &expr;
|
||||||
lit: syn::Lit::Str(lit),
|
while let syn::Expr::Group(e) = value {
|
||||||
..
|
value = &e.expr;
|
||||||
}) => Ok(Some(lit)),
|
}
|
||||||
expr => {
|
if let syn::Expr::Lit(syn::ExprLit {
|
||||||
cx.error_spanned_by(
|
lit: syn::Lit::Str(lit),
|
||||||
expr,
|
..
|
||||||
format!(
|
}) = value
|
||||||
"expected serde {} attribute to be a string: `{} = \"...\"`",
|
{
|
||||||
attr_name, meta_item_name
|
Ok(Some(lit.clone()))
|
||||||
),
|
} else {
|
||||||
);
|
cx.error_spanned_by(
|
||||||
Ok(None)
|
expr,
|
||||||
}
|
format!(
|
||||||
|
"expected serde {} attribute to be a string: `{} = \"...\"`",
|
||||||
|
attr_name, meta_item_name
|
||||||
|
),
|
||||||
|
);
|
||||||
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user