Skip to content

Commit 07a9854

Browse files
committed
Deduplicate is_comparison impl between BinOpKind and AssocOp
1 parent bb78dba commit 07a9854

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

compiler/rustc_ast/src/ast.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -920,14 +920,8 @@ impl BinOpKind {
920920
matches!(self, BinOpKind::And | BinOpKind::Or)
921921
}
922922

923-
pub fn is_comparison(&self) -> bool {
924-
use BinOpKind::*;
925-
// Note for developers: please keep this match exhaustive;
926-
// we want compilation to fail if another variant is added.
927-
match *self {
928-
Eq | Lt | Le | Ne | Gt | Ge => true,
929-
And | Or | Add | Sub | Mul | Div | Rem | BitXor | BitAnd | BitOr | Shl | Shr => false,
930-
}
923+
pub fn is_comparison(self) -> bool {
924+
crate::util::parser::AssocOp::from_ast_binop(self).is_comparison()
931925
}
932926

933927
/// Returns `true` if the binary operator takes its arguments by value.

0 commit comments

Comments
 (0)