mirror of
https://github.com/OMGeeky/confique.git
synced 2026-01-18 01:17:42 +01:00
Error on unexpected extra tokens in attribute
This commit is contained in:
@@ -175,6 +175,7 @@ impl Parse for InternalAttr {
|
||||
"default" => {
|
||||
let _: Token![=] = input.parse()?;
|
||||
let expr = Expr::from_lit(input.parse()?)?;
|
||||
assert_empty(input)?;
|
||||
Ok(Self::Default(expr))
|
||||
}
|
||||
|
||||
@@ -182,3 +183,11 @@ impl Parse for InternalAttr {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_empty(input: ParseStream) -> Result<(), Error> {
|
||||
if input.is_empty() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::new(input.span(), "unexpected tokens, expected no more tokens in this context"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user