Skip to content

Commit 65e2a14

Browse files
committed
Auto merge of rust-lang#40266 - Mark-Simulacrum:cleanup-parser, r=petrochenkov
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).
2 parents 6b76c9e + 69899b7 commit 65e2a14

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/libsyntax/parse/parser.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1032,13 +1032,6 @@ impl<'a> Parser<'a> {
10321032
self.check_unknown_macro_variable();
10331033
}
10341034

1035-
/// Advance the parser by one token and return the bumped token.
1036-
pub fn bump_and_get(&mut self) -> token::Token {
1037-
let old_token = mem::replace(&mut self.token, token::Underscore);
1038-
self.bump();
1039-
old_token
1040-
}
1041-
10421035
/// Advance the parser using provided token as a next one. Use this when
10431036
/// consuming a part of a token. For example a single `<` from `<<`.
10441037
pub fn bump_with(&mut self,
@@ -2663,7 +2656,12 @@ impl<'a> Parser<'a> {
26632656
}));
26642657
},
26652658
token::CloseDelim(_) | token::Eof => unreachable!(),
2666-
_ => Ok(TokenTree::Token(self.span, self.bump_and_get())),
2659+
_ => {
2660+
let token = mem::replace(&mut self.token, token::Underscore);
2661+
let res = Ok(TokenTree::Token(self.span, token));
2662+
self.bump();
2663+
res
2664+
}
26672665
}
26682666
}
26692667

0 commit comments

Comments
 (0)