about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-09-28 11:29:47 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-10-03 11:42:29 +1100
commit40e4827fd2ad3b050bfaaf7450ed5e6a5407ff9d (patch)
tree8eaa5d9becf590bfbe296af499094bd892d91abc
parentbbb53bf7727f07c1ea6d7e2d36dc51fbfc6b6726 (diff)
downloadrust-40e4827fd2ad3b050bfaaf7450ed5e6a5407ff9d.tar.gz
rust-40e4827fd2ad3b050bfaaf7450ed5e6a5407ff9d.zip
Rewrite `Token::is_op`.
An exhaustive match is more readable and more future-proof.
-rw-r--r--compiler/rustc_ast/src/token.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs
index 99034799b3c..16224d71e45 100644
--- a/compiler/rustc_ast/src/token.rs
+++ b/compiler/rustc_ast/src/token.rs
@@ -345,17 +345,14 @@ impl Token {
     }
 
     pub fn is_op(&self) -> bool {
-        !matches!(
-            self.kind,
-            OpenDelim(..)
-                | CloseDelim(..)
-                | Literal(..)
-                | DocComment(..)
-                | Ident(..)
-                | Lifetime(..)
-                | Interpolated(..)
-                | Eof
-        )
+        match self.kind {
+            Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | BinOp(_)
+            | BinOpEq(_) | At | Dot | DotDot | DotDotDot | DotDotEq | Comma | Semi | Colon
+            | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar | Question | SingleQuote => true,
+
+            OpenDelim(..) | CloseDelim(..) | Literal(..) | DocComment(..) | Ident(..)
+            | Lifetime(..) | Interpolated(..) | Eof => false,
+        }
     }
 
     pub fn is_like_plus(&self) -> bool {