]> git.lizzy.rs Git - rust.git/commitdiff
Merge #852
authorbors[bot] <bors[bot]@users.noreply.github.com>
Mon, 18 Feb 2019 09:13:51 +0000 (09:13 +0000)
committerbors[bot] <bors[bot]@users.noreply.github.com>
Mon, 18 Feb 2019 09:13:51 +0000 (09:13 +0000)
852: Handle != r=flodiebold a=matklad

r? @flodiebold

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
crates/ra_hir/src/ty.rs
crates/ra_hir/src/ty/snapshots/tests__infer_binary_op.snap
crates/ra_hir/src/ty/tests.rs
crates/ra_syntax/src/ast.rs

index fb98ac907e56589039e43bd2a9bbec0833d167bd..d4d8966732afd5e3ecef7d0d8d67f3f33a2c7578 100644 (file)
@@ -861,6 +861,7 @@ fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty {
         BinaryOp::BooleanOr
         | BinaryOp::BooleanAnd
         | BinaryOp::EqualityTest
+        | BinaryOp::NegatedEqualityTest
         | BinaryOp::LesserEqualTest
         | BinaryOp::GreaterEqualTest
         | BinaryOp::LesserTest
index b9dda2bc073cafb2045e8b9abb3e7393fceee114..80ffe6e11f32f95575a60f687c19a8c17b190a12 100644 (file)
@@ -1,13 +1,13 @@
 ---
-created: "2019-01-26T17:46:03.853259898+00:00"
-creator: insta@0.5.2
-expression: "&result"
+created: "2019-02-18T07:03:52.524808301Z"
+creator: insta@0.6.2
 source: crates/ra_hir/src/ty/tests.rs
+expression: "&result"
 ---
 [6; 7) 'x': bool
 [22; 34) '{     0i32 }': i32
 [28; 32) '0i32': i32
-[54; 350) '{     ... < 3 }': bool
+[54; 370) '{     ... < 3 }': bool
 [64; 65) 'x': bool
 [68; 69) 'a': bool
 [68; 74) 'a && b': bool
@@ -20,34 +20,38 @@ source: crates/ra_hir/src/ty/tests.rs
 [115; 116) 'x': bool
 [115; 121) 'x == y': bool
 [120; 121) 'y': bool
-[131; 142) 'minus_forty': isize
-[152; 160) '-40isize': isize
-[153; 160) '40isize': isize
-[170; 171) 'h': bool
-[174; 185) 'minus_forty': isize
-[174; 196) 'minus_...ONST_2': bool
-[189; 196) 'CONST_2': isize
-[206; 207) 'c': i32
-[210; 211) 'f': fn f(bool) -> i32
-[210; 219) 'f(z || y)': i32
-[210; 223) 'f(z || y) + 5': i32
-[212; 213) 'z': bool
-[212; 218) 'z || y': bool
-[217; 218) 'y': bool
-[222; 223) '5': i32
-[233; 234) 'd': [unknown]
-[237; 238) 'b': [unknown]
-[248; 249) 'g': ()
-[252; 263) 'minus_forty': isize
-[252; 268) 'minus_...y ^= i': ()
-[267; 268) 'i': isize
-[278; 281) 'ten': usize
-[291; 293) '10': usize
-[303; 316) 'ten_is_eleven': bool
-[319; 322) 'ten': usize
-[319; 334) 'ten == some_num': bool
-[326; 334) 'some_num': usize
-[341; 344) 'ten': usize
-[341; 348) 'ten < 3': bool
-[347; 348) '3': usize
+[131; 132) 't': bool
+[135; 136) 'x': bool
+[135; 141) 'x != y': bool
+[140; 141) 'y': bool
+[151; 162) 'minus_forty': isize
+[172; 180) '-40isize': isize
+[173; 180) '40isize': isize
+[190; 191) 'h': bool
+[194; 205) 'minus_forty': isize
+[194; 216) 'minus_...ONST_2': bool
+[209; 216) 'CONST_2': isize
+[226; 227) 'c': i32
+[230; 231) 'f': fn f(bool) -> i32
+[230; 239) 'f(z || y)': i32
+[230; 243) 'f(z || y) + 5': i32
+[232; 233) 'z': bool
+[232; 238) 'z || y': bool
+[237; 238) 'y': bool
+[242; 243) '5': i32
+[253; 254) 'd': [unknown]
+[257; 258) 'b': [unknown]
+[268; 269) 'g': ()
+[272; 283) 'minus_forty': isize
+[272; 288) 'minus_...y ^= i': ()
+[287; 288) 'i': isize
+[298; 301) 'ten': usize
+[311; 313) '10': usize
+[323; 336) 'ten_is_eleven': bool
+[339; 342) 'ten': usize
+[339; 354) 'ten == some_num': bool
+[346; 354) 'some_num': usize
+[361; 364) 'ten': usize
+[361; 368) 'ten < 3': bool
+[367; 368) '3': usize
 
index 5eb9c4f5bcc8c7de160167f902ddeab9017624ba..4ab442b8a4d82eacaeac2ea2c1fbff74c46834d6 100644 (file)
@@ -239,6 +239,7 @@ fn test() -> bool {
     let x = a && b;
     let y = true || false;
     let z = x == y;
+    let t = x != y;
     let minus_forty: isize = -40isize;
     let h = minus_forty <= CONST_2;
     let c = f(z || y) + 5;
index 350f01f3359c5c5ce4f09fe48158c573769129b2..62641c9fef8b460677c36d2dd27f5100d7d7f1da 100644 (file)
@@ -535,6 +535,8 @@ pub enum BinOp {
     BooleanAnd,
     /// The `==` operator for equality testing
     EqualityTest,
+    /// The `!=` operator for equality testing
+    NegatedEqualityTest,
     /// The `<=` operator for lesser-equal testing
     LesserEqualTest,
     /// The `>=` operator for greater-equal testing
@@ -569,7 +571,7 @@ pub enum BinOp {
     RangeRightClosed,
     /// The `=` operator for assignment
     Assignment,
-    /// The `+=` operator for assignment after additon
+    /// The `+=` operator for assignment after addition
     AddAssign,
     /// The `/=` operator for assignment after division
     DivAssign,
@@ -599,6 +601,7 @@ pub fn op(&self) -> Option<BinOp> {
                 PIPEPIPE => Some(BinOp::BooleanOr),
                 AMPAMP => Some(BinOp::BooleanAnd),
                 EQEQ => Some(BinOp::EqualityTest),
+                NEQ => Some(BinOp::NegatedEqualityTest),
                 LTEQ => Some(BinOp::LesserEqualTest),
                 GTEQ => Some(BinOp::GreaterEqualTest),
                 L_ANGLE => Some(BinOp::LesserTest),