From ad80a0c551458de7d27a98d182d7f559de04f291 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 31 Jan 2019 18:51:17 +0300 Subject: preserve token spacing --- crates/ra_macros/src/mbe_parser.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'crates/ra_macros/src/mbe_parser.rs') diff --git a/crates/ra_macros/src/mbe_parser.rs b/crates/ra_macros/src/mbe_parser.rs index 279ab2f25..483594590 100644 --- a/crates/ra_macros/src/mbe_parser.rs +++ b/crates/ra_macros/src/mbe_parser.rs @@ -28,16 +28,14 @@ fn parse_subtree(tt: &tt::Subtree) -> Option { while let Some(tt) = p.eat() { let child: mbe::TokenTree = match tt { tt::TokenTree::Leaf(leaf) => match leaf { - tt::Leaf::Punct(tt::Punct { char: '$' }) => { + tt::Leaf::Punct(tt::Punct { char: '$', .. }) => { if p.at_ident().is_some() { mbe::Leaf::from(parse_var(&mut p)?).into() } else { parse_repeat(&mut p)?.into() } } - tt::Leaf::Punct(tt::Punct { char }) => { - mbe::Leaf::from(mbe::Punct { char: *char }).into() - } + tt::Leaf::Punct(punct) => mbe::Leaf::from(*punct).into(), tt::Leaf::Ident(tt::Ident { text }) => { mbe::Leaf::from(mbe::Ident { text: text.clone() }).into() } @@ -78,7 +76,7 @@ fn parse_repeat(p: &mut TtCursor) -> Option { let sep = p.eat_punct()?; let (separator, rep) = match sep.char { '*' | '+' | '?' => (None, sep.char), - char => (Some(mbe::Punct { char }), p.eat_punct()?.char), + char => (Some(char), p.eat_punct()?.char), }; let kind = match rep { -- cgit v1.2.3