Skip to content

Commit 7b2299a

Browse files
committed
Use impl PartialEq<TokenKind> for Token more.
This lets us compare a `Token` with a `TokenKind`. It's used a lot, but can be used even more, avoiding the need for some `.kind` uses.
1 parent 57af02c commit 7b2299a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Diff for: src/parse/macros/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ pub(crate) struct ParsedMacroArgs {
8484
fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
8585
for &keyword in RUST_KW.iter() {
8686
if parser.token.is_keyword(keyword)
87-
&& parser.look_ahead(1, |t| {
88-
t.kind == TokenKind::Eof || t.kind == TokenKind::Comma
89-
})
87+
&& parser.look_ahead(1, |t| *t == TokenKind::Eof || *t == TokenKind::Comma)
9088
{
9189
parser.bump();
9290
return Some(MacroArg::Keyword(
@@ -131,7 +129,7 @@ pub(crate) fn parse_macro_args(
131129
Some(arg) => {
132130
args.push(arg);
133131
parser.bump();
134-
if parser.token.kind == TokenKind::Eof && args.len() == 2 {
132+
if parser.token == TokenKind::Eof && args.len() == 2 {
135133
vec_with_semi = true;
136134
break;
137135
}
@@ -150,7 +148,7 @@ pub(crate) fn parse_macro_args(
150148

151149
parser.bump();
152150

153-
if parser.token.kind == TokenKind::Eof {
151+
if parser.token == TokenKind::Eof {
154152
trailing_comma = true;
155153
break;
156154
}

0 commit comments

Comments
 (0)