]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/type_repetition_in_bounds.rs
New upstream version 1.52.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / type_repetition_in_bounds.rs
CommitLineData
f20569fa
XL
1#![deny(clippy::type_repetition_in_bounds)]
2
3use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
4
5pub fn foo<T>(_t: T)
6where
7 T: Copy,
8 T: Clone,
9{
10 unimplemented!();
11}
12
13pub fn bar<T, U>(_t: T, _u: U)
14where
15 T: Copy,
16 U: Clone,
17{
18 unimplemented!();
19}
20
21// Threshold test (see #4380)
22trait LintBounds
23where
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
31trait LotsOfBounds
32where
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)
40mod 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)
56extern crate serde;
57mod 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
72fn main() {}