about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-03-05 19:53:29 +0000
committerbors <bors@rust-lang.org>2017-03-05 19:53:29 +0000
commit65e2a1454f86f759bca475b0956b8e60bf86cabd (patch)
tree89c0c325255e513d33b016a9bdb1ff11113438e8 /src/libsyntax/parse
parent6b76c9ea19f4538a6ace44ebce2b8bfd1f80c126 (diff)
parent69899b7f27b1a9511abea9d2187def6967d7d7f7 (diff)
downloadrust-65e2a1454f86f759bca475b0956b8e60bf86cabd.tar.gz
rust-65e2a1454f86f759bca475b0956b8e60bf86cabd.zip
Auto merge of #40266 - Mark-Simulacrum:cleanup-parser, r=petrochenkov
Inline function to avoid naming confusion.

Fixes the non-RFC requiring portion of #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).
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 6e3724b5fd8..6c566dab1d6 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -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,
@@ -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
+            }
         }
     }