From 3e9aa3e46bd5906469751c908a0daedfe26dac22 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 1 Sep 2019 22:46:03 +0200 Subject: Make make_parser into a proc_macro_attribute That way rustfmt will format the contents of the parser. --- dhall_proc_macros/src/parser.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'dhall_proc_macros/src/parser.rs') diff --git a/dhall_proc_macros/src/parser.rs b/dhall_proc_macros/src/parser.rs index 2618bec..1c75279 100644 --- a/dhall_proc_macros/src/parser.rs +++ b/dhall_proc_macros/src/parser.rs @@ -4,8 +4,8 @@ use syn::parse::{Parse, ParseStream, Result}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; use syn::{ - bracketed, parenthesized, parse_quote, token, Error, Expr, Ident, ItemFn, - Pat, ReturnType, Token, Type, + braced, bracketed, parenthesized, parse_quote, token, Error, Expr, Ident, + ItemFn, Pat, ReturnType, Token, Type, }; mod rule_kw { @@ -58,9 +58,13 @@ struct ParseChildrenInput { impl Parse for Rules { fn parse(input: ParseStream) -> Result { + let _: Token![impl ] = input.parse()?; + let _: Token![_] = input.parse()?; + let contents; + braced!(contents in input); let mut rules = Vec::new(); - while !input.is_empty() { - rules.push(input.parse()?) + while !contents.is_empty() { + rules.push(contents.parse()?) } Ok(Rules(rules)) } -- cgit v1.2.3