diff options
author | Aleksey Kladov <[email protected]> | 2019-08-17 15:51:01 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-08-17 15:51:01 +0100 |
commit | b082cd679ad1ae7646d03261bcccda435443365c (patch) | |
tree | a3f2f1386853c5a02907705ee2be418a130fe3e4 /crates/ra_hir/src/expr.rs | |
parent | 7e5a186c1fe585aac95019addc963bf74cb112ae (diff) |
normalize ordering ops
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index ea3fa4417..5430a0c9f 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -273,12 +273,14 @@ pub enum LogicOp { | |||
273 | 273 | ||
274 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] | 274 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] |
275 | pub enum CmpOp { | 275 | pub enum CmpOp { |
276 | Equal, | 276 | Eq { negated: bool }, |
277 | NotEqual, | 277 | Ord { ordering: Ordering, strict: bool }, |
278 | } | ||
279 | |||
280 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] | ||
281 | pub enum Ordering { | ||
278 | Less, | 282 | Less, |
279 | LessOrEqual, | ||
280 | Greater, | 283 | Greater, |
281 | GreaterOrEqual, | ||
282 | } | 284 | } |
283 | 285 | ||
284 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] | 286 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] |
@@ -1080,12 +1082,20 @@ impl From<ast::BinOp> for BinaryOp { | |||
1080 | match ast_op { | 1082 | match ast_op { |
1081 | ast::BinOp::BooleanOr => BinaryOp::LogicOp(LogicOp::Or), | 1083 | ast::BinOp::BooleanOr => BinaryOp::LogicOp(LogicOp::Or), |
1082 | ast::BinOp::BooleanAnd => BinaryOp::LogicOp(LogicOp::And), | 1084 | ast::BinOp::BooleanAnd => BinaryOp::LogicOp(LogicOp::And), |
1083 | ast::BinOp::EqualityTest => BinaryOp::CmpOp(CmpOp::Equal), | 1085 | ast::BinOp::EqualityTest => BinaryOp::CmpOp(CmpOp::Eq { negated: false }), |
1084 | ast::BinOp::NegatedEqualityTest => BinaryOp::CmpOp(CmpOp::NotEqual), | 1086 | ast::BinOp::NegatedEqualityTest => BinaryOp::CmpOp(CmpOp::Eq { negated: true }), |
1085 | ast::BinOp::LesserEqualTest => BinaryOp::CmpOp(CmpOp::LessOrEqual), | 1087 | ast::BinOp::LesserEqualTest => { |
1086 | ast::BinOp::GreaterEqualTest => BinaryOp::CmpOp(CmpOp::GreaterOrEqual), | 1088 | BinaryOp::CmpOp(CmpOp::Ord { ordering: Ordering::Less, strict: false }) |
1087 | ast::BinOp::LesserTest => BinaryOp::CmpOp(CmpOp::Less), | 1089 | } |
1088 | ast::BinOp::GreaterTest => BinaryOp::CmpOp(CmpOp::Greater), | 1090 | ast::BinOp::GreaterEqualTest => { |
1091 | BinaryOp::CmpOp(CmpOp::Ord { ordering: Ordering::Greater, strict: false }) | ||
1092 | } | ||
1093 | ast::BinOp::LesserTest => { | ||
1094 | BinaryOp::CmpOp(CmpOp::Ord { ordering: Ordering::Less, strict: true }) | ||
1095 | } | ||
1096 | ast::BinOp::GreaterTest => { | ||
1097 | BinaryOp::CmpOp(CmpOp::Ord { ordering: Ordering::Greater, strict: true }) | ||
1098 | } | ||
1089 | ast::BinOp::Addition => BinaryOp::ArithOp(ArithOp::Add), | 1099 | ast::BinOp::Addition => BinaryOp::ArithOp(ArithOp::Add), |
1090 | ast::BinOp::Multiplication => BinaryOp::ArithOp(ArithOp::Mul), | 1100 | ast::BinOp::Multiplication => BinaryOp::ArithOp(ArithOp::Mul), |
1091 | ast::BinOp::Subtraction => BinaryOp::ArithOp(ArithOp::Sub), | 1101 | ast::BinOp::Subtraction => BinaryOp::ArithOp(ArithOp::Sub), |