]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/suspicious_arithmetic_impl.rs
Merge pull request #2574 from mark-i-m/i128
[rust.git] / tests / ui / suspicious_arithmetic_impl.rs
index 097627e1d7c28fc3548dd50af869a5431c275e14..d5982efe12fbc8c7c722771d6c945940a0d85c9a 100644 (file)
@@ -45,6 +45,28 @@ fn div(self, other: Self) -> Self {
     }
 }
 
+struct Bar(i32);
+
+impl Add for Bar {
+    type Output = Bar;
+
+    fn add(self, other: Self) -> Self {
+        Bar(self.0 & !other.0) // OK: UnNot part of BiExpr as child node
+    }
+}
+
+impl Sub for Bar {
+    type Output = Bar;
+
+    fn sub(self, other: Self) -> Self {
+        if self.0 <= other.0 {
+            Bar(-(self.0 & other.0)) // OK: UnNeg part of BiExpr as parent node
+        } else {
+            Bar(0)
+        }
+    }
+}
+
 fn main() {}
 
 fn do_nothing(x: u32) -> u32 {