Produce errors on attr that fails to parse as Meta

This commit is contained in:
David Tolnay
2019-09-07 22:46:50 -07:00
parent 0d4722680a
commit a3157c9572
2 changed files with 27 additions and 13 deletions
+5
View File
@@ -38,6 +38,11 @@ impl Ctxt {
.push(syn::Error::new_spanned(obj.into_token_stream(), msg));
}
/// Add one of Syn's parse errors.
pub fn syn_error(&self, err: syn::Error) {
self.errors.borrow_mut().as_mut().unwrap().push(err);
}
/// Consume this object, producing a formatted error string if there are errors.
pub fn check(self) -> Result<(), Vec<syn::Error>> {
let errors = self.errors.borrow_mut().take().unwrap();