Avoid cloning the contents of a TokenStream
in a few places
This commit is contained in:
parent
cb2462c53f
commit
f6aec82d4d
3 changed files with 12 additions and 11 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue