diff options
| author | bors <bors@rust-lang.org> | 2021-01-09 19:33:23 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-09 19:33:23 +0000 |
| commit | 6184f23950fb4aa14884ce310d948dc6fca269a3 (patch) | |
| tree | fa11fe0c624da8971e56cfe0a8e7a3da19c5f401 /compiler/rustc_parse/src/parser | |
| parent | d0beb70a657380d919d919985d9affcce954753a (diff) | |
| parent | 7b36408b5f6373647eba37ad1f91c26070298454 (diff) | |
| download | rust-6184f23950fb4aa14884ce310d948dc6fca269a3.tar.gz rust-6184f23950fb4aa14884ce310d948dc6fca269a3.zip | |
Auto merge of #80830 - Aaron1011:capture-token-empty-stack, r=petrochenkov
Use an empty `TokenCursorFrame` stack when capturing tokens We will never need to pop past our starting frame during token capturing. Using an empty stack allows us to avoid pointless heap allocations/deallocations.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 073e62c41d3..cecf0130cf7 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1239,7 +1239,15 @@ impl<'a> Parser<'a> { f: impl FnOnce(&mut Self) -> PResult<'a, R>, ) -> PResult<'a, (R, Option<LazyTokenStream>)> { let start_token = (self.token.clone(), self.token_spacing); - let cursor_snapshot = self.token_cursor.clone(); + 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 ret = f(self)?; |
