Skip to content

Commit

Permalink
Use impl PartialEq<TokenKind> for Token more.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nnethercote committed Aug 14, 2024
1 parent 57af02c commit 7b2299a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/parse/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ pub(crate) struct ParsedMacroArgs {
fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
for &keyword in RUST_KW.iter() {
if parser.token.is_keyword(keyword)
&& parser.look_ahead(1, |t| {
t.kind == TokenKind::Eof || t.kind == TokenKind::Comma
})
&& parser.look_ahead(1, |t| *t == TokenKind::Eof || *t == TokenKind::Comma)
{
parser.bump();
return Some(MacroArg::Keyword(
Expand Down Expand Up @@ -131,7 +129,7 @@ pub(crate) fn parse_macro_args(
Some(arg) => {
args.push(arg);
parser.bump();
if parser.token.kind == TokenKind::Eof && args.len() == 2 {
if parser.token == TokenKind::Eof && args.len() == 2 {
vec_with_semi = true;
break;
}
Expand All @@ -150,7 +148,7 @@ pub(crate) fn parse_macro_args(

parser.bump();

if parser.token.kind == TokenKind::Eof {
if parser.token == TokenKind::Eof {
trailing_comma = true;
break;
}
Expand Down

0 comments on commit 7b2299a

Please sign in to comment.