Skip to content

Commit 3c4c859

Browse files
committed
Rename Parser::last_token_kind as prev_token_kind.
Likewise, rename LastTokenKind as PrevTokenKind. This is a [breaking-change] for libsyntax.
1 parent 2747923 commit 3c4c859

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ fn maybe_append(mut lhs: Vec<Attribute>, rhs: Option<Vec<Attribute>>)
238238
}
239239

240240
#[derive(PartialEq)]
241-
enum LastTokenKind {
241+
enum PrevTokenKind {
242242
DocComment,
243243
Comma,
244244
Interpolated,
@@ -258,7 +258,7 @@ pub struct Parser<'a> {
258258
pub prev_span: Span,
259259
pub cfg: CrateConfig,
260260
/// the previous token kind
261-
last_token_kind: LastTokenKind,
261+
prev_token_kind: PrevTokenKind,
262262
pub buffer: [TokenAndSpan; 4],
263263
pub buffer_start: isize,
264264
pub buffer_end: isize,
@@ -369,7 +369,7 @@ impl<'a> Parser<'a> {
369369
token: tok0.tok,
370370
span: span,
371371
prev_span: span,
372-
last_token_kind: LastTokenKind::Other,
372+
prev_token_kind: PrevTokenKind::Other,
373373
buffer: [
374374
placeholder.clone(),
375375
placeholder.clone(),
@@ -504,7 +504,7 @@ impl<'a> Parser<'a> {
504504
expr: PResult<'a, P<Expr>>)
505505
-> PResult<'a, (Span, P<Expr>)> {
506506
expr.map(|e| {
507-
if self.last_token_kind == LastTokenKind::Interpolated {
507+
if self.prev_token_kind == PrevTokenKind::Interpolated {
508508
(self.prev_span, e)
509509
} else {
510510
(e.span, e)
@@ -524,7 +524,7 @@ impl<'a> Parser<'a> {
524524
self.bug("ident interpolation not converted to real token");
525525
}
526526
_ => {
527-
Err(if self.last_token_kind == LastTokenKind::DocComment {
527+
Err(if self.prev_token_kind == PrevTokenKind::DocComment {
528528
self.span_fatal_help(self.prev_span,
529529
"found a documentation comment that doesn't document anything",
530530
"doc comments must come before what they document, maybe a comment was \
@@ -922,20 +922,20 @@ impl<'a> Parser<'a> {
922922

923923
/// Advance the parser by one token
924924
pub fn bump(&mut self) {
925-
if self.last_token_kind == LastTokenKind::Eof {
925+
if self.prev_token_kind == PrevTokenKind::Eof {
926926
// Bumping after EOF is a bad sign, usually an infinite loop.
927927
self.bug("attempted to bump the parser past EOF (may be stuck in a loop)");
928928
}
929929

930930
self.prev_span = self.span;
931931

932932
// Record last token kind for possible error recovery.
933-
self.last_token_kind = match self.token {
934-
token::DocComment(..) => LastTokenKind::DocComment,
935-
token::Comma => LastTokenKind::Comma,
936-
token::Interpolated(..) => LastTokenKind::Interpolated,
937-
token::Eof => LastTokenKind::Eof,
938-
_ => LastTokenKind::Other,
933+
self.prev_token_kind = match self.token {
934+
token::DocComment(..) => PrevTokenKind::DocComment,
935+
token::Comma => PrevTokenKind::Comma,
936+
token::Interpolated(..) => PrevTokenKind::Interpolated,
937+
token::Eof => PrevTokenKind::Eof,
938+
_ => PrevTokenKind::Other,
939939
};
940940

941941
let next = if self.buffer_start == self.buffer_end {
@@ -976,8 +976,8 @@ impl<'a> Parser<'a> {
976976
self.prev_span = mk_sp(self.span.lo, lo);
977977
// It would be incorrect to record the kind of the current token, but
978978
// fortunately for tokens currently using `bump_with`, the
979-
// last_token_kind will be of no use anyway.
980-
self.last_token_kind = LastTokenKind::Other;
979+
// prev_token_kind will be of no use anyway.
980+
self.prev_token_kind = PrevTokenKind::Other;
981981
self.span = mk_sp(lo, hi);
982982
self.token = next;
983983
self.expected_tokens.clear();
@@ -2950,7 +2950,7 @@ impl<'a> Parser<'a> {
29502950
self.expected_tokens.push(TokenType::Operator);
29512951
while let Some(op) = AssocOp::from_token(&self.token) {
29522952

2953-
let lhs_span = if self.last_token_kind == LastTokenKind::Interpolated {
2953+
let lhs_span = if self.prev_token_kind == PrevTokenKind::Interpolated {
29542954
self.prev_span
29552955
} else {
29562956
lhs.span
@@ -4019,7 +4019,7 @@ impl<'a> Parser<'a> {
40194019
None => {
40204020
let unused_attrs = |attrs: &[_], s: &mut Self| {
40214021
if attrs.len() > 0 {
4022-
if s.last_token_kind == LastTokenKind::DocComment {
4022+
if s.prev_token_kind == PrevTokenKind::DocComment {
40234023
s.span_err_help(s.prev_span,
40244024
"found a documentation comment that doesn't document anything",
40254025
"doc comments must come before what they document, maybe a \
@@ -4338,7 +4338,7 @@ impl<'a> Parser<'a> {
43384338

43394339
let missing_comma = !lifetimes.is_empty() &&
43404340
!self.token.is_like_gt() &&
4341-
self.last_token_kind != LastTokenKind::Comma;
4341+
self.prev_token_kind != PrevTokenKind::Comma;
43424342

43434343
if missing_comma {
43444344

0 commit comments

Comments
 (0)