mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
introduce bump as a better-checked alternative to bump_any
This commit is contained in:
parent
e2b378ef7e
commit
d8aa9a1d81
2 changed files with 8 additions and 2 deletions
|
@ -126,7 +126,7 @@ pub(crate) mod fragments {
|
||||||
|
|
||||||
while !p.at(EOF) {
|
while !p.at(EOF) {
|
||||||
if p.at(T![;]) {
|
if p.at(T![;]) {
|
||||||
p.bump_any();
|
p.bump(T![;]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ fn opt_visibility(p: &mut Parser) -> bool {
|
||||||
match p.current() {
|
match p.current() {
|
||||||
T![pub] => {
|
T![pub] => {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
p.bump_any();
|
p.bump(T![pub]);
|
||||||
if p.at(T!['(']) {
|
if p.at(T!['(']) {
|
||||||
match p.nth(1) {
|
match p.nth(1) {
|
||||||
// test crate_visibility
|
// test crate_visibility
|
||||||
|
|
|
@ -170,6 +170,12 @@ impl<'t> Parser<'t> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Advances the parser by one token, asserting that it is exactly the expected token
|
||||||
|
pub(crate) fn bump(&mut self, expected: SyntaxKind) {
|
||||||
|
debug_assert!(self.nth(0) == expected);
|
||||||
|
self.bump_any()
|
||||||
|
}
|
||||||
|
|
||||||
/// Advances the parser by one token, remapping its kind.
|
/// Advances the parser by one token, remapping its kind.
|
||||||
/// This is useful to create contextual keywords from
|
/// This is useful to create contextual keywords from
|
||||||
/// identifiers. For example, the lexer creates an `union`
|
/// identifiers. For example, the lexer creates an `union`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue