diff options
| author | Daniel Grunwald <daniel@danielgrunwald.de> | 2015-01-08 01:44:01 +0100 |
|---|---|---|
| committer | Daniel Grunwald <daniel@danielgrunwald.de> | 2015-01-08 01:44:01 +0100 |
| commit | 1cc69c484eadec5e54f178a9fcfaff21b5d25cf4 (patch) | |
| tree | 1be1f1d2b71077fd4d26822431d00475bd9c57a9 /src/libsyntax/ast_util.rs | |
| parent | 9e4e524e0eb17c8f463e731f23b544003e8709c6 (diff) | |
| download | rust-1cc69c484eadec5e54f178a9fcfaff21b5d25cf4.tar.gz rust-1cc69c484eadec5e54f178a9fcfaff21b5d25cf4.zip | |
RFC 558: Require parentheses for chained comparisons
Fixes #20724.
Diffstat (limited to 'src/libsyntax/ast_util.rs')
| -rw-r--r-- | src/libsyntax/ast_util.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 871f1237aee..836deeffde1 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -85,6 +85,13 @@ pub fn is_shift_binop(b: BinOp) -> bool { } } +pub fn is_comparison_binop(b: BinOp) -> bool { + match b { + BiEq | BiLt | BiLe | BiNe | BiGt | BiGe => true, + _ => false + } +} + /// Returns `true` if the binary operator takes its arguments by value pub fn is_by_value_binop(b: BinOp) -> bool { match b { @@ -317,8 +324,7 @@ pub fn operator_prec(op: ast::BinOp) -> uint { BiBitAnd => 8u, BiBitXor => 7u, BiBitOr => 6u, - BiLt | BiLe | BiGe | BiGt => 4u, - BiEq | BiNe => 3u, + BiLt | BiLe | BiGe | BiGt | BiEq | BiNe => 3u, BiAnd => 2u, BiOr => 1u } |
