Skip to content

Commit 40e4827

Browse files
committed
Rewrite Token::is_op.
An exhaustive match is more readable and more future-proof.
1 parent bbb53bf commit 40e4827

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

compiler/rustc_ast/src/token.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,14 @@ impl Token {
345345
}
346346

347347
pub fn is_op(&self) -> bool {
348-
!matches!(
349-
self.kind,
350-
OpenDelim(..)
351-
| CloseDelim(..)
352-
| Literal(..)
353-
| DocComment(..)
354-
| Ident(..)
355-
| Lifetime(..)
356-
| Interpolated(..)
357-
| Eof
358-
)
348+
match self.kind {
349+
Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | BinOp(_)
350+
| BinOpEq(_) | At | Dot | DotDot | DotDotDot | DotDotEq | Comma | Semi | Colon
351+
| ModSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question | SingleQuote => true,
352+
353+
OpenDelim(..) | CloseDelim(..) | Literal(..) | DocComment(..) | Ident(..)
354+
| Lifetime(..) | Interpolated(..) | Eof => false,
355+
}
359356
}
360357

361358
pub fn is_like_plus(&self) -> bool {

0 commit comments

Comments
 (0)