]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/trait_duplication_in_bounds.rs
Rollup merge of #102072 - scottmcm:ptr-alignment-type, r=thomcc
[rust.git] / src / tools / clippy / tests / ui / trait_duplication_in_bounds.rs
1 // run-rustfix
2 #![deny(clippy::trait_duplication_in_bounds)]
3 #![allow(unused)]
4
5 fn bad_foo<T: Clone + Clone + Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) {
6     unimplemented!();
7 }
8
9 fn bad_bar<T, U>(arg0: T, arg1: U)
10 where
11     T: Clone + Clone + Clone + Copy,
12     U: Clone + Copy,
13 {
14     unimplemented!();
15 }
16
17 fn good_bar<T: Clone + Copy, U: Clone + Copy>(arg0: T, arg1: U) {
18     unimplemented!();
19 }
20
21 fn good_foo<T, U>(arg0: T, arg1: U)
22 where
23     T: Clone + Copy,
24     U: Clone + Copy,
25 {
26     unimplemented!();
27 }
28
29 trait GoodSelfTraitBound: Clone + Copy {
30     fn f();
31 }
32
33 trait GoodSelfWhereClause {
34     fn f()
35     where
36         Self: Clone + Copy;
37 }
38
39 trait BadSelfTraitBound: Clone + Clone + Clone {
40     fn f();
41 }
42
43 trait BadSelfWhereClause {
44     fn f()
45     where
46         Self: Clone + Clone + Clone;
47 }
48
49 trait GoodTraitBound<T: Clone + Copy, U: Clone + Copy> {
50     fn f();
51 }
52
53 trait GoodWhereClause<T, U> {
54     fn f()
55     where
56         T: Clone + Copy,
57         U: Clone + Copy;
58 }
59
60 trait BadTraitBound<T: Clone + Clone + Clone + Copy, U: Clone + Copy> {
61     fn f();
62 }
63
64 trait BadWhereClause<T, U> {
65     fn f()
66     where
67         T: Clone + Clone + Clone + Copy,
68         U: Clone + Copy;
69 }
70
71 struct GoodStructBound<T: Clone + Copy, U: Clone + Copy> {
72     t: T,
73     u: U,
74 }
75
76 impl<T: Clone + Copy, U: Clone + Copy> GoodTraitBound<T, U> for GoodStructBound<T, U> {
77     // this should not warn
78     fn f() {}
79 }
80
81 struct GoodStructWhereClause;
82
83 impl<T, U> GoodTraitBound<T, U> for GoodStructWhereClause
84 where
85     T: Clone + Copy,
86     U: Clone + Copy,
87 {
88     // this should not warn
89     fn f() {}
90 }
91
92 fn no_error_separate_arg_bounds(program: impl AsRef<()>, dir: impl AsRef<()>, args: &[impl AsRef<()>]) {}
93
94 trait GenericTrait<T> {}
95
96 fn good_generic<T: GenericTrait<u64> + GenericTrait<u32>>(arg0: T) {
97     unimplemented!();
98 }
99
100 fn bad_generic<T: GenericTrait<u64> + GenericTrait<u32> + GenericTrait<u64>>(arg0: T) {
101     unimplemented!();
102 }
103
104 mod foo {
105     pub trait Clone {}
106 }
107
108 fn qualified_path<T: std::clone::Clone + Clone + foo::Clone>(arg0: T) {
109     unimplemented!();
110 }
111
112 fn main() {}