]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/tests/ui/type_repetition_in_bounds.rs
Merge branch 'master' into hooks
[rust.git] / src / tools / clippy / tests / ui / type_repetition_in_bounds.rs
index 8b538be762b0c3bb9821171388e33c85c99f1fea..766190f209977fcec1a70bd9f5ae9a4ec467c603 100644 (file)
@@ -1,4 +1,6 @@
-#[deny(clippy::type_repetition_in_bounds)]
+#![deny(clippy::type_repetition_in_bounds)]
+
+use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
 
 pub fn foo<T>(_t: T)
 where
@@ -16,4 +18,55 @@ pub fn bar<T, U>(_t: T, _u: U)
     unimplemented!();
 }
 
+// Threshold test (see #4380)
+trait LintBounds
+where
+    Self: Clone,
+    Self: Copy + Default + Ord,
+    Self: Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign,
+    Self: Mul<Output = Self> + MulAssign + Div<Output = Self> + DivAssign,
+{
+}
+
+trait LotsOfBounds
+where
+    Self: Clone + Copy + Default + Ord,
+    Self: Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign,
+    Self: Mul<Output = Self> + MulAssign + Div<Output = Self> + DivAssign,
+{
+}
+
+// Generic distinction (see #4323)
+mod issue4323 {
+    pub struct Foo<A>(A);
+    pub struct Bar<A, B> {
+        a: Foo<A>,
+        b: Foo<B>,
+    }
+
+    impl<A, B> Unpin for Bar<A, B>
+    where
+        Foo<A>: Unpin,
+        Foo<B>: Unpin,
+    {
+    }
+}
+
+// Extern macros shouldn't lint (see #4326)
+extern crate serde;
+mod issue4326 {
+    use serde::{Deserialize, Serialize};
+
+    trait Foo {}
+    impl Foo for String {}
+
+    #[derive(Debug, Serialize, Deserialize)]
+    struct Bar<S>
+    where
+        S: Foo,
+    {
+        foo: S,
+    }
+}
+
 fn main() {}