diff options
author | Edwin Cheng <[email protected]> | 2019-05-02 14:24:51 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-05-02 14:24:51 +0100 |
commit | 35c463315032dcebb38f738cca57581608f19826 (patch) | |
tree | 6a48f9cbdf7ecd94488d1fd1705b95c96515272f /crates/ra_mbe/src/tt_cursor.rs | |
parent | b0e7022afe17f35fd0f6960a279e375b19061919 (diff) |
Make `vis` matcher optional and fix typo
Diffstat (limited to 'crates/ra_mbe/src/tt_cursor.rs')
-rw-r--r-- | crates/ra_mbe/src/tt_cursor.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/ra_mbe/src/tt_cursor.rs b/crates/ra_mbe/src/tt_cursor.rs index 8f15d215b..d85ab43e4 100644 --- a/crates/ra_mbe/src/tt_cursor.rs +++ b/crates/ra_mbe/src/tt_cursor.rs | |||
@@ -149,9 +149,16 @@ impl<'a> TtCursor<'a> { | |||
149 | self.eat_ident().cloned().map(|ident| tt::Leaf::from(ident).into()) | 149 | self.eat_ident().cloned().map(|ident| tt::Leaf::from(ident).into()) |
150 | } | 150 | } |
151 | 151 | ||
152 | pub(crate) fn eat_vis(&mut self) -> Option<tt::TokenTree> { | 152 | pub(crate) fn try_eat_vis(&mut self) -> Option<tt::TokenTree> { |
153 | // `vis` matcher is optional | ||
154 | let old_pos = self.pos; | ||
153 | let parser = Parser::new(&mut self.pos, self.subtree); | 155 | let parser = Parser::new(&mut self.pos, self.subtree); |
154 | parser.parse_vis() | 156 | |
157 | let res = parser.parse_vis(); | ||
158 | if res.is_none() { | ||
159 | self.pos = old_pos; | ||
160 | } | ||
161 | res | ||
155 | } | 162 | } |
156 | 163 | ||
157 | pub(crate) fn expect_char(&mut self, char: char) -> Result<(), ParseError> { | 164 | pub(crate) fn expect_char(&mut self, char: char) -> Result<(), ParseError> { |