]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/type_repetition_in_bounds.rs
Merge commit '2ca58e7dda4a9eb142599638c59dc04d15961175' into clippyup
[rust.git] / src / tools / clippy / tests / ui / type_repetition_in_bounds.rs
1 #![deny(clippy::type_repetition_in_bounds)]
2
3 use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
4
5 pub fn foo<T>(_t: T)
6 where
7     T: Copy,
8     T: Clone,
9 {
10     unimplemented!();
11 }
12
13 pub fn bar<T, U>(_t: T, _u: U)
14 where
15     T: Copy,
16     U: Clone,
17 {
18     unimplemented!();
19 }
20
21 // Threshold test (see #4380)
22 trait LintBounds
23 where
24     Self: Clone,
25     Self: Copy + Default + Ord,
26     Self: Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign,
27     Self: Mul<Output = Self> + MulAssign + Div<Output = Self> + DivAssign,
28 {
29 }
30
31 trait LotsOfBounds
32 where
33     Self: Clone + Copy + Default + Ord,
34     Self: Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign,
35     Self: Mul<Output = Self> + MulAssign + Div<Output = Self> + DivAssign,
36 {
37 }
38
39 // Generic distinction (see #4323)
40 mod issue4323 {
41     pub struct Foo<A>(A);
42     pub struct Bar<A, B> {
43         a: Foo<A>,
44         b: Foo<B>,
45     }
46
47     impl<A, B> Unpin for Bar<A, B>
48     where
49         Foo<A>: Unpin,
50         Foo<B>: Unpin,
51     {
52     }
53 }
54
55 // Extern macros shouldn't lint (see #4326)
56 extern crate serde;
57 mod issue4326 {
58     use serde::{Deserialize, Serialize};
59
60     trait Foo {}
61     impl Foo for String {}
62
63     #[derive(Debug, Serialize, Deserialize)]
64     struct Bar<S>
65     where
66         S: Foo,
67     {
68         foo: S,
69     }
70 }
71
72 fn main() {}