Skip to content

Commit

Permalink
Auto merge of rust-lang#40266 - Mark-Simulacrum:cleanup-parser, r=pet…
Browse files Browse the repository at this point in the history
…rochenkov

Inline function to avoid naming confusion.

Fixes the non-RFC requiring portion of rust-lang#18394. The suggestion for a new token there probably needs to either be refiled onto rust-lang/rfcs if it's still relevant (may not be given Macros 2.0 work, not sure).
  • Loading branch information
bors committed Mar 5, 2017
2 parents 6b76c9e + 69899b7 commit 65e2a14
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,13 +1032,6 @@ impl<'a> Parser<'a> {
self.check_unknown_macro_variable();
}

/// Advance the parser by one token and return the bumped token.
pub fn bump_and_get(&mut self) -> token::Token {
let old_token = mem::replace(&mut self.token, token::Underscore);
self.bump();
old_token
}

/// Advance the parser using provided token as a next one. Use this when
/// consuming a part of a token. For example a single `<` from `<<`.
pub fn bump_with(&mut self,
Expand Down Expand Up @@ -2663,7 +2656,12 @@ impl<'a> Parser<'a> {
}));
},
token::CloseDelim(_) | token::Eof => unreachable!(),
_ => Ok(TokenTree::Token(self.span, self.bump_and_get())),
_ => {
let token = mem::replace(&mut self.token, token::Underscore);
let res = Ok(TokenTree::Token(self.span, token));
self.bump();
res
}
}
}

Expand Down

0 comments on commit 65e2a14

Please sign in to comment.