diff options
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r-- | crates/ra_parser/src/grammar.rs | 4 | ||||
-rw-r--r-- | crates/ra_parser/src/parser.rs | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index 89f4b63ec..4e6f2f558 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs | |||
@@ -126,7 +126,7 @@ pub(crate) mod fragments { | |||
126 | 126 | ||
127 | while !p.at(EOF) { | 127 | while !p.at(EOF) { |
128 | if p.at(T![;]) { | 128 | if p.at(T![;]) { |
129 | p.bump_any(); | 129 | p.bump(T![;]); |
130 | continue; | 130 | continue; |
131 | } | 131 | } |
132 | 132 | ||
@@ -179,7 +179,7 @@ fn opt_visibility(p: &mut Parser) -> bool { | |||
179 | match p.current() { | 179 | match p.current() { |
180 | T![pub] => { | 180 | T![pub] => { |
181 | let m = p.start(); | 181 | let m = p.start(); |
182 | p.bump_any(); | 182 | p.bump(T![pub]); |
183 | if p.at(T!['(']) { | 183 | if p.at(T!['(']) { |
184 | match p.nth(1) { | 184 | match p.nth(1) { |
185 | // test crate_visibility | 185 | // test crate_visibility |
diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs index ccacaacad..d8567e84b 100644 --- a/crates/ra_parser/src/parser.rs +++ b/crates/ra_parser/src/parser.rs | |||
@@ -170,6 +170,12 @@ impl<'t> Parser<'t> { | |||
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | /// Advances the parser by one token, asserting that it is exactly the expected token | ||
174 | pub(crate) fn bump(&mut self, expected: SyntaxKind) { | ||
175 | debug_assert!(self.nth(0) == expected); | ||
176 | self.bump_any() | ||
177 | } | ||
178 | |||
173 | /// Advances the parser by one token, remapping its kind. | 179 | /// Advances the parser by one token, remapping its kind. |
174 | /// This is useful to create contextual keywords from | 180 | /// This is useful to create contextual keywords from |
175 | /// identifiers. For example, the lexer creates an `union` | 181 | /// identifiers. For example, the lexer creates an `union` |