⬆️ rust-analyzer

Merge commit '368e0bb32f'
This commit is contained in:
arcnmx 2023-01-09 10:36:22 -08:00
parent b3ef934ccb
commit 25242fe93f
395 changed files with 14569 additions and 5755 deletions

View file

@ -148,11 +148,16 @@ impl<'t> Parser<'t> {
kinds.contains(self.current())
}
/// Checks if the current token is contextual keyword with text `t`.
/// Checks if the current token is contextual keyword `kw`.
pub(crate) fn at_contextual_kw(&self, kw: SyntaxKind) -> bool {
self.inp.contextual_kind(self.pos) == kw
}
/// Checks if the nth token is contextual keyword `kw`.
pub(crate) fn nth_at_contextual_kw(&self, n: usize, kw: SyntaxKind) -> bool {
self.inp.contextual_kind(self.pos + n) == kw
}
/// Starts a new node in the syntax tree. All nodes and tokens
/// consumed between the `start` and the corresponding `Marker::complete`
/// belong to the same node.
@ -162,7 +167,7 @@ impl<'t> Parser<'t> {
Marker::new(pos)
}
/// Consume the next token if `kind` matches.
/// Consume the next token. Panics if the parser isn't currently at `kind`.
pub(crate) fn bump(&mut self, kind: SyntaxKind) {
assert!(self.eat(kind));
}
@ -205,7 +210,7 @@ impl<'t> Parser<'t> {
if self.eat(kind) {
return true;
}
self.error(format!("expected {:?}", kind));
self.error(format!("expected {kind:?}"));
false
}
@ -237,6 +242,7 @@ impl<'t> Parser<'t> {
fn do_bump(&mut self, kind: SyntaxKind, n_raw_tokens: u8) {
self.pos += n_raw_tokens as usize;
self.steps.set(0);
self.push_event(Event::Token { kind, n_raw_tokens });
}