From 07a9854b5ca416f17ac1429db15f6f5b2f847404 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 10 Apr 2024 10:53:24 +0000 Subject: [PATCH] Deduplicate `is_comparison` impl between `BinOpKind` and `AssocOp` --- compiler/rustc_ast/src/ast.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 63ce6685e43..5b708cf4e1a 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -920,14 +920,8 @@ pub fn is_lazy(&self) -> bool { matches!(self, BinOpKind::And | BinOpKind::Or) } - pub fn is_comparison(&self) -> bool { - use BinOpKind::*; - // Note for developers: please keep this match exhaustive; - // we want compilation to fail if another variant is added. - match *self { - Eq | Lt | Le | Ne | Gt | Ge => true, - And | Or | Add | Sub | Mul | Div | Rem | BitXor | BitAnd | BitOr | Shl | Shr => false, - } + pub fn is_comparison(self) -> bool { + crate::util::parser::AssocOp::from_ast_binop(self).is_comparison() } /// Returns `true` if the binary operator takes its arguments by value.