#![deny(clippy::trait_duplication_in_bounds)] #![allow(unused)] use std::collections::BTreeMap; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; fn bad_foo(arg0: T, arg1: Z) where T: Clone, T: Default, { unimplemented!(); } fn good_bar(arg: T) { unimplemented!(); } fn good_foo(arg: T) where T: Clone + Default, { unimplemented!(); } fn good_foobar(arg: T) where T: Clone, { unimplemented!(); } trait T: Default { fn f() where Self: Default; } trait U: Default { fn f() where Self: Clone; } trait ZZ: Default { fn g(); fn h(); fn f() where Self: Default + Clone; } trait BadTrait: Default + Clone { fn f() where Self: Default + Clone; fn g() where Self: Default; fn h() where Self: Copy; } #[derive(Default, Clone)] struct Life; impl T for Life { // this should not warn fn f() {} } impl U for Life { // this should not warn fn f() {} } // should not warn trait Iter: Iterator { fn into_group_btreemap(self) -> BTreeMap> where Self: Iterator + Sized, K: Ord + Eq, { unimplemented!(); } } struct Foo; trait FooIter: Iterator { fn bar() where Self: Iterator, { } } // This should not lint fn impl_trait(_: impl AsRef, _: impl AsRef) {} mod repeated_where_clauses_or_trait_bounds { fn bad_foo(arg0: T, argo1: U) { unimplemented!(); } fn bad_bar(arg0: T, arg1: U) where T: Clone + Clone + Clone + Copy, U: Clone + Copy, { unimplemented!(); } fn good_bar(arg0: T, arg1: U) { unimplemented!(); } fn good_foo(arg0: T, arg1: U) where T: Clone + Copy, U: Clone + Copy, { unimplemented!(); } trait GoodSelfTraitBound: Clone + Copy { fn f(); } trait GoodSelfWhereClause { fn f() where Self: Clone + Copy; } trait BadSelfTraitBound: Clone + Clone + Clone { fn f(); } trait BadSelfWhereClause { fn f() where Self: Clone + Clone + Clone; } trait GoodTraitBound { fn f(); } trait GoodWhereClause { fn f() where T: Clone + Copy, U: Clone + Copy; } trait BadTraitBound { fn f(); } trait BadWhereClause { fn f() where T: Clone + Clone + Clone + Copy, U: Clone + Copy; } struct GoodStructBound { t: T, u: U, } impl GoodTraitBound for GoodStructBound { // this should not warn fn f() {} } struct GoodStructWhereClause; impl GoodTraitBound for GoodStructWhereClause where T: Clone + Copy, U: Clone + Copy, { // this should not warn fn f() {} } fn no_error_separate_arg_bounds(program: impl AsRef<()>, dir: impl AsRef<()>, args: &[impl AsRef<()>]) {} trait GenericTrait {} // This should not warn but currently does see #8757 fn good_generic + GenericTrait>(arg0: T) { unimplemented!(); } fn bad_generic + GenericTrait + GenericTrait>(arg0: T) { unimplemented!(); } mod foo { pub trait Clone {} } fn qualified_path(arg0: T) { unimplemented!(); } } fn main() {}