}
#[derive(PartialEq)]
-enum LastTokenKind {
+enum PrevTokenKind {
DocComment,
Comma,
Interpolated,
pub prev_span: Span,
pub cfg: CrateConfig,
/// the previous token kind
- last_token_kind: LastTokenKind,
+ prev_token_kind: PrevTokenKind,
pub buffer: [TokenAndSpan; 4],
pub buffer_start: isize,
pub buffer_end: isize,
token: tok0.tok,
span: span,
prev_span: span,
- last_token_kind: LastTokenKind::Other,
+ prev_token_kind: PrevTokenKind::Other,
buffer: [
placeholder.clone(),
placeholder.clone(),
expr: PResult<'a, P<Expr>>)
-> PResult<'a, (Span, P<Expr>)> {
expr.map(|e| {
- if self.last_token_kind == LastTokenKind::Interpolated {
+ if self.prev_token_kind == PrevTokenKind::Interpolated {
(self.prev_span, e)
} else {
(e.span, e)
self.bug("ident interpolation not converted to real token");
}
_ => {
- Err(if self.last_token_kind == LastTokenKind::DocComment {
+ Err(if self.prev_token_kind == PrevTokenKind::DocComment {
self.span_fatal_help(self.prev_span,
"found a documentation comment that doesn't document anything",
"doc comments must come before what they document, maybe a comment was \
/// Advance the parser by one token
pub fn bump(&mut self) {
- if self.last_token_kind == LastTokenKind::Eof {
+ if self.prev_token_kind == PrevTokenKind::Eof {
// Bumping after EOF is a bad sign, usually an infinite loop.
self.bug("attempted to bump the parser past EOF (may be stuck in a loop)");
}
self.prev_span = self.span;
// Record last token kind for possible error recovery.
- self.last_token_kind = match self.token {
- token::DocComment(..) => LastTokenKind::DocComment,
- token::Comma => LastTokenKind::Comma,
- token::Interpolated(..) => LastTokenKind::Interpolated,
- token::Eof => LastTokenKind::Eof,
- _ => LastTokenKind::Other,
+ self.prev_token_kind = match self.token {
+ token::DocComment(..) => PrevTokenKind::DocComment,
+ token::Comma => PrevTokenKind::Comma,
+ token::Interpolated(..) => PrevTokenKind::Interpolated,
+ token::Eof => PrevTokenKind::Eof,
+ _ => PrevTokenKind::Other,
};
let next = if self.buffer_start == self.buffer_end {
self.prev_span = mk_sp(self.span.lo, lo);
// It would be incorrect to record the kind of the current token, but
// fortunately for tokens currently using `bump_with`, the
- // last_token_kind will be of no use anyway.
- self.last_token_kind = LastTokenKind::Other;
+ // prev_token_kind will be of no use anyway.
+ self.prev_token_kind = PrevTokenKind::Other;
self.span = mk_sp(lo, hi);
self.token = next;
self.expected_tokens.clear();
self.expected_tokens.push(TokenType::Operator);
while let Some(op) = AssocOp::from_token(&self.token) {
- let lhs_span = if self.last_token_kind == LastTokenKind::Interpolated {
+ let lhs_span = if self.prev_token_kind == PrevTokenKind::Interpolated {
self.prev_span
} else {
lhs.span
None => {
let unused_attrs = |attrs: &[_], s: &mut Self| {
if attrs.len() > 0 {
- if s.last_token_kind == LastTokenKind::DocComment {
+ if s.prev_token_kind == PrevTokenKind::DocComment {
s.span_err_help(s.prev_span,
"found a documentation comment that doesn't document anything",
"doc comments must come before what they document, maybe a \
let missing_comma = !lifetimes.is_empty() &&
!self.token.is_like_gt() &&
- self.last_token_kind != LastTokenKind::Comma;
+ self.prev_token_kind != PrevTokenKind::Comma;
if missing_comma {