aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_macros/src/mbe_parser.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-31 15:51:17 +0000
committerAleksey Kladov <[email protected]>2019-01-31 20:23:30 +0000
commitad80a0c551458de7d27a98d182d7f559de04f291 (patch)
tree20a3e85a30a45365fe31360cb57b4f53a17b9a28 /crates/ra_macros/src/mbe_parser.rs
parent59347388541388347e86de9718bd69994c113203 (diff)
preserve token spacing
Diffstat (limited to 'crates/ra_macros/src/mbe_parser.rs')
-rw-r--r--crates/ra_macros/src/mbe_parser.rs8
1 files changed, 3 insertions, 5 deletions
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<mbe::Subtree> {
28 while let Some(tt) = p.eat() { 28 while let Some(tt) = p.eat() {
29 let child: mbe::TokenTree = match tt { 29 let child: mbe::TokenTree = match tt {
30 tt::TokenTree::Leaf(leaf) => match leaf { 30 tt::TokenTree::Leaf(leaf) => match leaf {
31 tt::Leaf::Punct(tt::Punct { char: '$' }) => { 31 tt::Leaf::Punct(tt::Punct { char: '$', .. }) => {
32 if p.at_ident().is_some() { 32 if p.at_ident().is_some() {
33 mbe::Leaf::from(parse_var(&mut p)?).into() 33 mbe::Leaf::from(parse_var(&mut p)?).into()
34 } else { 34 } else {
35 parse_repeat(&mut p)?.into() 35 parse_repeat(&mut p)?.into()
36 } 36 }
37 } 37 }
38 tt::Leaf::Punct(tt::Punct { char }) => { 38 tt::Leaf::Punct(punct) => mbe::Leaf::from(*punct).into(),
39 mbe::Leaf::from(mbe::Punct { char: *char }).into()
40 }
41 tt::Leaf::Ident(tt::Ident { text }) => { 39 tt::Leaf::Ident(tt::Ident { text }) => {
42 mbe::Leaf::from(mbe::Ident { text: text.clone() }).into() 40 mbe::Leaf::from(mbe::Ident { text: text.clone() }).into()
43 } 41 }
@@ -78,7 +76,7 @@ fn parse_repeat(p: &mut TtCursor) -> Option<mbe::Repeat> {
78 let sep = p.eat_punct()?; 76 let sep = p.eat_punct()?;
79 let (separator, rep) = match sep.char { 77 let (separator, rep) = match sep.char {
80 '*' | '+' | '?' => (None, sep.char), 78 '*' | '+' | '?' => (None, sep.char),
81 char => (Some(mbe::Punct { char }), p.eat_punct()?.char), 79 char => (Some(char), p.eat_punct()?.char),
82 }; 80 };
83 81
84 let kind = match rep { 82 let kind = match rep {