refactor: use by-ref TokenTree iterator to avoid a few clones
This commit is contained in:
parent
5b24e12785
commit
05c5df5682
3 changed files with 6 additions and 6 deletions
|
@ -1882,8 +1882,8 @@ declare_lint_pass!(
|
|||
struct UnderMacro(bool);
|
||||
|
||||
impl KeywordIdents {
|
||||
fn check_tokens(&mut self, cx: &EarlyContext<'_>, tokens: TokenStream) {
|
||||
for tt in tokens.into_trees() {
|
||||
fn check_tokens(&mut self, cx: &EarlyContext<'_>, tokens: &TokenStream) {
|
||||
for tt in tokens.trees() {
|
||||
match tt {
|
||||
// Only report non-raw idents.
|
||||
TokenTree::Token(token, _) => {
|
||||
|
@ -1944,10 +1944,10 @@ impl KeywordIdents {
|
|||
|
||||
impl EarlyLintPass for KeywordIdents {
|
||||
fn check_mac_def(&mut self, cx: &EarlyContext<'_>, mac_def: &ast::MacroDef) {
|
||||
self.check_tokens(cx, mac_def.body.tokens.clone());
|
||||
self.check_tokens(cx, &mac_def.body.tokens);
|
||||
}
|
||||
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::MacCall) {
|
||||
self.check_tokens(cx, mac.args.tokens.clone());
|
||||
self.check_tokens(cx, &mac.args.tokens);
|
||||
}
|
||||
fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: Ident) {
|
||||
self.check_ident_token(cx, UnderMacro(false), ident);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue