]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/op_ref.rs
iterate List by value
[rust.git] / tests / ui / op_ref.rs
index 1112b6794cfeca4811a510033f3786d8ad23034b..6605c967c8e7e6323d659f0a7c645e0cd59832c2 100644 (file)
@@ -1,15 +1,8 @@
-// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 #![allow(unused_variables, clippy::blacklisted_name)]
-
+#![warn(clippy::op_ref)]
+#![allow(clippy::many_single_char_names)]
 use std::collections::HashSet;
+use std::ops::BitAnd;
 
 fn main() {
     let tracked_fds: HashSet<i32> = HashSet::new();
@@ -27,4 +20,39 @@ fn main() {
     if b < &a {
         println!("OK");
     }
+
+    struct X(i32);
+    impl BitAnd for X {
+        type Output = X;
+        fn bitand(self, rhs: X) -> X {
+            X(self.0 & rhs.0)
+        }
+    }
+    impl<'a> BitAnd<&'a X> for X {
+        type Output = X;
+        fn bitand(self, rhs: &'a X) -> X {
+            X(self.0 & rhs.0)
+        }
+    }
+    let x = X(1);
+    let y = X(2);
+    let z = x & &y;
+
+    #[derive(Copy, Clone)]
+    struct Y(i32);
+    impl BitAnd for Y {
+        type Output = Y;
+        fn bitand(self, rhs: Y) -> Y {
+            Y(self.0 & rhs.0)
+        }
+    }
+    impl<'a> BitAnd<&'a Y> for Y {
+        type Output = Y;
+        fn bitand(self, rhs: &'a Y) -> Y {
+            Y(self.0 & rhs.0)
+        }
+    }
+    let x = Y(1);
+    let y = Y(2);
+    let z = x & &y;
 }