1 #![deny(clippy::trait_duplication_in_bounds)]
4 use std::collections::BTreeMap;
5 use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
7 fn bad_foo<T: Clone + Default, Z: Copy>(arg0: T, arg1: Z)
15 fn good_bar<T: Clone + Default>(arg: T) {
19 fn good_foo<T>(arg: T)
26 fn good_foobar<T: Default>(arg: T)
50 Self: Default + Clone;
53 trait BadTrait: Default + Clone {
56 Self: Default + Clone;
65 #[derive(Default, Clone)]
69 // this should not warn
74 // this should not warn
79 trait Iter: Iterator {
80 fn into_group_btreemap<K, V>(self) -> BTreeMap<K, Vec<V>>
82 Self: Iterator<Item = (K, V)> + Sized,
91 trait FooIter: Iterator<Item = Foo> {
94 Self: Iterator<Item = Foo>,
99 // This should not lint
100 fn impl_trait(_: impl AsRef<str>, _: impl AsRef<str>) {}
102 mod repeated_where_clauses_or_trait_bounds {
103 fn bad_foo<T: Clone + Clone + Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) {
107 fn bad_bar<T, U>(arg0: T, arg1: U)
109 T: Clone + Clone + Clone + Copy,
115 fn good_bar<T: Clone + Copy, U: Clone + Copy>(arg0: T, arg1: U) {
119 fn good_foo<T, U>(arg0: T, arg1: U)
127 trait GoodSelfTraitBound: Clone + Copy {
131 trait GoodSelfWhereClause {
137 trait BadSelfTraitBound: Clone + Clone + Clone {
141 trait BadSelfWhereClause {
144 Self: Clone + Clone + Clone;
147 trait GoodTraitBound<T: Clone + Copy, U: Clone + Copy> {
151 trait GoodWhereClause<T, U> {
158 trait BadTraitBound<T: Clone + Clone + Clone + Copy, U: Clone + Copy> {
162 trait BadWhereClause<T, U> {
165 T: Clone + Clone + Clone + Copy,
169 struct GoodStructBound<T: Clone + Copy, U: Clone + Copy> {
174 impl<T: Clone + Copy, U: Clone + Copy> GoodTraitBound<T, U> for GoodStructBound<T, U> {
175 // this should not warn
179 struct GoodStructWhereClause;
181 impl<T, U> GoodTraitBound<T, U> for GoodStructWhereClause
186 // this should not warn
190 fn no_error_separate_arg_bounds(program: impl AsRef<()>, dir: impl AsRef<()>, args: &[impl AsRef<()>]) {}
192 trait GenericTrait<T> {}
194 // This should not warn but currently does see #8757
195 fn good_generic<T: GenericTrait<u64> + GenericTrait<u32>>(arg0: T) {
199 fn bad_generic<T: GenericTrait<u64> + GenericTrait<u32> + GenericTrait<u64>>(arg0: T) {
207 fn qualified_path<T: std::clone::Clone + Clone + foo::Clone>(arg0: T) {