Improve atribute parse compiler error

This commit is contained in:
Gustavo
2024-02-27 08:31:46 -03:00
parent 02f47b8866
commit 2506ff5d70
+6 -1
View File
@@ -29,11 +29,16 @@ macro_rules! impl_parse {
fn parse($input: syn::parse::ParseStream) -> syn::Result<Self> {
let mut $out = $i::default();
loop {
let span = $input.span();
let key: Ident = $input.call(syn::ext::IdentExt::parse_any)?;
match &*key.to_string() {
$($k => $e,)*
#[allow(unreachable_patterns)]
_ => syn_err!($input.span(); "unexpected attribute")
x => syn_err!(
span;
"Unknown attribute \"{x}\". Allowed attributes are: {}",
[$(stringify!($k),)*].join(", ")
)
}
match $input.is_empty() {