about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2021-01-31 01:47:34 +0100
committerGitHub <noreply@github.com>2021-01-31 01:47:34 +0100
commit3e8ae5dcba4e5ad2f9a543df8da1ea679d84e4ce (patch)
tree9c32337ac1b6d8863f07e854099db63db6249336 /compiler/rustc_parse/src/parser
parent84b6f46d6e4bbbb0ab951ac1aede0d48cf183c26 (diff)
parent5d739180cde7f7350b7a90e8a7542bd9c4cd6783 (diff)
downloadrust-3e8ae5dcba4e5ad2f9a543df8da1ea679d84e4ce.tar.gz
rust-3e8ae5dcba4e5ad2f9a543df8da1ea679d84e4ce.zip
Rollup merge of #81472 - Aaron1011:fix/revert-cursor-clone, r=petrochenkov
Clone entire `TokenCursor` when collecting tokens

Reverts PR #80830
Fixes taiki-e/pin-project#312

We can have an arbitrary number of `None`-delimited group frames pushed
on the stack due to proc-macro invocations, which can legally be exited.
Attempting to account for this would add a lot of complexity for a tiny
performance gain, so let's just use the original strategy.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs10
1 files changed, 1 insertions, 9 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index c575c821964..e2af63d1744 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -1254,15 +1254,7 @@ impl<'a> Parser<'a> {
         f: impl FnOnce(&mut Self) -> PResult<'a, (R, TrailingToken)>,
     ) -> PResult<'a, R> {
         let start_token = (self.token.clone(), self.token_spacing);
-        let cursor_snapshot = TokenCursor {
-            frame: self.token_cursor.frame.clone(),
-            // We only ever capture tokens within our current frame,
-            // so we can just use an empty frame stack
-            stack: vec![],
-            desugar_doc_comments: self.token_cursor.desugar_doc_comments,
-            num_next_calls: self.token_cursor.num_next_calls,
-            append_unglued_token: self.token_cursor.append_unglued_token.clone(),
-        };
+        let cursor_snapshot = self.token_cursor.clone();
 
         let (mut ret, trailing_token) = f(self)?;