#![deny(clippy::trait_duplication_in_bounds)] #![allow(unused)] #![feature(const_trait_impl)] use std::any::Any; fn bad_foo(arg0: T, argo1: U) { unimplemented!(); } fn bad_bar(arg0: T, arg1: U) where T: 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 { fn f(); } trait BadSelfWhereClause { fn f() where Self: 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 + 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 {} fn good_generic + GenericTrait>(arg0: T) { unimplemented!(); } fn bad_generic + GenericTrait>(arg0: T) { unimplemented!(); } mod foo { pub trait Clone {} } fn qualified_path(arg0: T) { unimplemented!(); } fn good_trait_object(arg0: &(dyn Any + Send)) { unimplemented!(); } fn bad_trait_object(arg0: &(dyn Any + Send)) { unimplemented!(); } trait Proj { type S; } impl Proj for () { type S = (); } impl Proj for i32 { type S = i32; } trait Base { fn is_base(&self); } trait Derived: Base + Base<()> { fn is_derived(&self); } fn f(obj: &dyn Derived

) { obj.is_derived(); Base::::is_base(obj); Base::<()>::is_base(obj); } // #13476 trait Value {} fn const_generic + Value<1>>() {} // #11067 and #9626 fn assoc_tys_generics<'a, 'b, T, U>() where T: IntoIterator + IntoIterator, U: From<&'a str> + From<&'b [u16]>, { } // #13476 #[const_trait] trait ConstTrait {} const fn const_trait_bounds_good() {} const fn const_trait_bounds_bad() {} //~^ trait_duplication_in_bounds fn projections() where U: ToOwned, V: ToOwned, T: IntoIterator, //~^ trait_duplication_in_bounds V: IntoIterator + IntoIterator, { } fn main() { let _x: fn(_) = f::<()>; let _x: fn(_) = f::; }