about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2020-09-14 01:45:10 -0400
committerAaron Hill <aa1ronham@gmail.com>2020-10-19 12:30:41 -0400
commitf6aec82d4d7c9a75698808c28454d601aceac06f (patch)
tree24f3ac5da74ae3a14330152c19de40bea04a38e6 /compiler/rustc_parse/src/parser
parentcb2462c53f2cc3f140c0f1ea0976261cab968a34 (diff)
downloadrust-f6aec82d4d7c9a75698808c28454d601aceac06f.tar.gz
rust-f6aec82d4d7c9a75698808c28454d601aceac06f.zip
Avoid cloning the contents of a `TokenStream` in a few places
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index 7970ad36456..1860f1238c4 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -833,15 +833,15 @@ impl<'a> Parser<'a> {
         }
 
         let frame = &self.token_cursor.frame;
-        looker(&match frame.tree_cursor.look_ahead(dist - 1) {
+        match frame.tree_cursor.look_ahead(dist - 1) {
             Some(tree) => match tree {
-                TokenTree::Token(token) => token,
+                TokenTree::Token(token) => looker(token),
                 TokenTree::Delimited(dspan, delim, _) => {
-                    Token::new(token::OpenDelim(delim), dspan.open)
+                    looker(&Token::new(token::OpenDelim(*delim), dspan.open))
                 }
             },
-            None => Token::new(token::CloseDelim(frame.delim), frame.span.close),
-        })
+            None => looker(&Token::new(token::CloseDelim(frame.delim), frame.span.close)),
+        }
     }
 
     /// Returns whether any of the given keywords are `dist` tokens ahead of the current one.