diff options
-rw-r--r-- | crates/ra_hir/src/ty.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap | 72 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 1 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 5 |
4 files changed, 44 insertions, 35 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index fb98ac907..d4d896673 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -861,6 +861,7 @@ fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { | |||
861 | BinaryOp::BooleanOr | 861 | BinaryOp::BooleanOr |
862 | | BinaryOp::BooleanAnd | 862 | | BinaryOp::BooleanAnd |
863 | | BinaryOp::EqualityTest | 863 | | BinaryOp::EqualityTest |
864 | | BinaryOp::NegatedEqualityTest | ||
864 | | BinaryOp::LesserEqualTest | 865 | | BinaryOp::LesserEqualTest |
865 | | BinaryOp::GreaterEqualTest | 866 | | BinaryOp::GreaterEqualTest |
866 | | BinaryOp::LesserTest | 867 | | BinaryOp::LesserTest |
diff --git a/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap b/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap index b9dda2bc0..80ffe6e11 100644 --- a/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap +++ b/crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap | |||
@@ -1,13 +1,13 @@ | |||
1 | --- | 1 | --- |
2 | created: "2019-01-26T17:46:03.853259898+00:00" | 2 | created: "2019-02-18T07:03:52.524808301Z" |
3 | creator: [email protected] | 3 | creator: [email protected] |
4 | expression: "&result" | ||
5 | source: crates/ra_hir/src/ty/tests.rs | 4 | source: crates/ra_hir/src/ty/tests.rs |
5 | expression: "&result" | ||
6 | --- | 6 | --- |
7 | [6; 7) 'x': bool | 7 | [6; 7) 'x': bool |
8 | [22; 34) '{ 0i32 }': i32 | 8 | [22; 34) '{ 0i32 }': i32 |
9 | [28; 32) '0i32': i32 | 9 | [28; 32) '0i32': i32 |
10 | [54; 350) '{ ... < 3 }': bool | 10 | [54; 370) '{ ... < 3 }': bool |
11 | [64; 65) 'x': bool | 11 | [64; 65) 'x': bool |
12 | [68; 69) 'a': bool | 12 | [68; 69) 'a': bool |
13 | [68; 74) 'a && b': bool | 13 | [68; 74) 'a && b': bool |
@@ -20,34 +20,38 @@ source: crates/ra_hir/src/ty/tests.rs | |||
20 | [115; 116) 'x': bool | 20 | [115; 116) 'x': bool |
21 | [115; 121) 'x == y': bool | 21 | [115; 121) 'x == y': bool |
22 | [120; 121) 'y': bool | 22 | [120; 121) 'y': bool |
23 | [131; 142) 'minus_forty': isize | 23 | [131; 132) 't': bool |
24 | [152; 160) '-40isize': isize | 24 | [135; 136) 'x': bool |
25 | [153; 160) '40isize': isize | 25 | [135; 141) 'x != y': bool |
26 | [170; 171) 'h': bool | 26 | [140; 141) 'y': bool |
27 | [174; 185) 'minus_forty': isize | 27 | [151; 162) 'minus_forty': isize |
28 | [174; 196) 'minus_...ONST_2': bool | 28 | [172; 180) '-40isize': isize |
29 | [189; 196) 'CONST_2': isize | 29 | [173; 180) '40isize': isize |
30 | [206; 207) 'c': i32 | 30 | [190; 191) 'h': bool |
31 | [210; 211) 'f': fn f(bool) -> i32 | 31 | [194; 205) 'minus_forty': isize |
32 | [210; 219) 'f(z || y)': i32 | 32 | [194; 216) 'minus_...ONST_2': bool |
33 | [210; 223) 'f(z || y) + 5': i32 | 33 | [209; 216) 'CONST_2': isize |
34 | [212; 213) 'z': bool | 34 | [226; 227) 'c': i32 |
35 | [212; 218) 'z || y': bool | 35 | [230; 231) 'f': fn f(bool) -> i32 |
36 | [217; 218) 'y': bool | 36 | [230; 239) 'f(z || y)': i32 |
37 | [222; 223) '5': i32 | 37 | [230; 243) 'f(z || y) + 5': i32 |
38 | [233; 234) 'd': [unknown] | 38 | [232; 233) 'z': bool |
39 | [237; 238) 'b': [unknown] | 39 | [232; 238) 'z || y': bool |
40 | [248; 249) 'g': () | 40 | [237; 238) 'y': bool |
41 | [252; 263) 'minus_forty': isize | 41 | [242; 243) '5': i32 |
42 | [252; 268) 'minus_...y ^= i': () | 42 | [253; 254) 'd': [unknown] |
43 | [267; 268) 'i': isize | 43 | [257; 258) 'b': [unknown] |
44 | [278; 281) 'ten': usize | 44 | [268; 269) 'g': () |
45 | [291; 293) '10': usize | 45 | [272; 283) 'minus_forty': isize |
46 | [303; 316) 'ten_is_eleven': bool | 46 | [272; 288) 'minus_...y ^= i': () |
47 | [319; 322) 'ten': usize | 47 | [287; 288) 'i': isize |
48 | [319; 334) 'ten == some_num': bool | 48 | [298; 301) 'ten': usize |
49 | [326; 334) 'some_num': usize | 49 | [311; 313) '10': usize |
50 | [341; 344) 'ten': usize | 50 | [323; 336) 'ten_is_eleven': bool |
51 | [341; 348) 'ten < 3': bool | 51 | [339; 342) 'ten': usize |
52 | [347; 348) '3': usize | 52 | [339; 354) 'ten == some_num': bool |
53 | [346; 354) 'some_num': usize | ||
54 | [361; 364) 'ten': usize | ||
55 | [361; 368) 'ten < 3': bool | ||
56 | [367; 368) '3': usize | ||
53 | 57 | ||
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 5eb9c4f5b..4ab442b8a 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -239,6 +239,7 @@ fn test() -> bool { | |||
239 | let x = a && b; | 239 | let x = a && b; |
240 | let y = true || false; | 240 | let y = true || false; |
241 | let z = x == y; | 241 | let z = x == y; |
242 | let t = x != y; | ||
242 | let minus_forty: isize = -40isize; | 243 | let minus_forty: isize = -40isize; |
243 | let h = minus_forty <= CONST_2; | 244 | let h = minus_forty <= CONST_2; |
244 | let c = f(z || y) + 5; | 245 | let c = f(z || y) + 5; |
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 350f01f33..62641c9fe 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -535,6 +535,8 @@ pub enum BinOp { | |||
535 | BooleanAnd, | 535 | BooleanAnd, |
536 | /// The `==` operator for equality testing | 536 | /// The `==` operator for equality testing |
537 | EqualityTest, | 537 | EqualityTest, |
538 | /// The `!=` operator for equality testing | ||
539 | NegatedEqualityTest, | ||
538 | /// The `<=` operator for lesser-equal testing | 540 | /// The `<=` operator for lesser-equal testing |
539 | LesserEqualTest, | 541 | LesserEqualTest, |
540 | /// The `>=` operator for greater-equal testing | 542 | /// The `>=` operator for greater-equal testing |
@@ -569,7 +571,7 @@ pub enum BinOp { | |||
569 | RangeRightClosed, | 571 | RangeRightClosed, |
570 | /// The `=` operator for assignment | 572 | /// The `=` operator for assignment |
571 | Assignment, | 573 | Assignment, |
572 | /// The `+=` operator for assignment after additon | 574 | /// The `+=` operator for assignment after addition |
573 | AddAssign, | 575 | AddAssign, |
574 | /// The `/=` operator for assignment after division | 576 | /// The `/=` operator for assignment after division |
575 | DivAssign, | 577 | DivAssign, |
@@ -599,6 +601,7 @@ impl BinExpr { | |||
599 | PIPEPIPE => Some(BinOp::BooleanOr), | 601 | PIPEPIPE => Some(BinOp::BooleanOr), |
600 | AMPAMP => Some(BinOp::BooleanAnd), | 602 | AMPAMP => Some(BinOp::BooleanAnd), |
601 | EQEQ => Some(BinOp::EqualityTest), | 603 | EQEQ => Some(BinOp::EqualityTest), |
604 | NEQ => Some(BinOp::NegatedEqualityTest), | ||
602 | LTEQ => Some(BinOp::LesserEqualTest), | 605 | LTEQ => Some(BinOp::LesserEqualTest), |
603 | GTEQ => Some(BinOp::GreaterEqualTest), | 606 | GTEQ => Some(BinOp::GreaterEqualTest), |
604 | L_ANGLE => Some(BinOp::LesserTest), | 607 | L_ANGLE => Some(BinOp::LesserTest), |