2022-07-13 06:25:19 -05:00
|
|
|
#![deny(clippy::trait_duplication_in_bounds)]
|
|
|
|
#![allow(unused)]
|
|
|
|
|
2023-04-30 07:45:45 -05:00
|
|
|
use std::any::Any;
|
|
|
|
|
2022-07-13 06:25:19 -05:00
|
|
|
fn bad_foo<T: Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bad_bar<T, U>(arg0: T, arg1: U)
|
|
|
|
where
|
|
|
|
T: Clone + Copy,
|
|
|
|
U: Clone + Copy,
|
|
|
|
{
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn good_bar<T: Clone + Copy, U: Clone + Copy>(arg0: T, arg1: U) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn good_foo<T, U>(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<T: Clone + Copy, U: Clone + Copy> {
|
|
|
|
fn f();
|
|
|
|
}
|
|
|
|
|
|
|
|
trait GoodWhereClause<T, U> {
|
|
|
|
fn f()
|
|
|
|
where
|
|
|
|
T: Clone + Copy,
|
|
|
|
U: Clone + Copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
trait BadTraitBound<T: Clone + Copy, U: Clone + Copy> {
|
|
|
|
fn f();
|
|
|
|
}
|
|
|
|
|
|
|
|
trait BadWhereClause<T, U> {
|
|
|
|
fn f()
|
|
|
|
where
|
|
|
|
T: Clone + Copy,
|
|
|
|
U: Clone + Copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct GoodStructBound<T: Clone + Copy, U: Clone + Copy> {
|
|
|
|
t: T,
|
|
|
|
u: U,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: Clone + Copy, U: Clone + Copy> GoodTraitBound<T, U> for GoodStructBound<T, U> {
|
|
|
|
// this should not warn
|
|
|
|
fn f() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct GoodStructWhereClause;
|
|
|
|
|
|
|
|
impl<T, U> GoodTraitBound<T, U> 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<T> {}
|
|
|
|
|
|
|
|
fn good_generic<T: GenericTrait<u64> + GenericTrait<u32>>(arg0: T) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
2022-08-29 23:33:56 -05:00
|
|
|
fn bad_generic<T: GenericTrait<u64> + GenericTrait<u32>>(arg0: T) {
|
2022-07-13 06:25:19 -05:00
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
mod foo {
|
|
|
|
pub trait Clone {}
|
|
|
|
}
|
|
|
|
|
2022-08-29 23:33:56 -05:00
|
|
|
fn qualified_path<T: std::clone::Clone + foo::Clone>(arg0: T) {
|
2022-07-13 06:25:19 -05:00
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
2023-04-30 07:45:45 -05:00
|
|
|
fn good_trait_object(arg0: &(dyn Any + Send)) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bad_trait_object(arg0: &(dyn Any + Send)) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
2024-01-16 05:13:15 -06:00
|
|
|
trait Proj {
|
|
|
|
type S;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Proj for () {
|
|
|
|
type S = ();
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Proj for i32 {
|
|
|
|
type S = i32;
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Base<T> {
|
|
|
|
fn is_base(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Derived<B: Proj>: Base<B::S> + Base<()> {
|
|
|
|
fn is_derived(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn f<P: Proj>(obj: &dyn Derived<P>) {
|
|
|
|
obj.is_derived();
|
|
|
|
Base::<P::S>::is_base(obj);
|
|
|
|
Base::<()>::is_base(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _x: fn(_) = f::<()>;
|
|
|
|
let _x: fn(_) = f::<i32>;
|
|
|
|
}
|