2020-08-11 08:43:21 -05:00
|
|
|
#![deny(clippy::trait_duplication_in_bounds)]
|
2022-07-18 02:39:37 -05:00
|
|
|
#![allow(unused)]
|
2020-08-11 08:43:21 -05:00
|
|
|
|
2022-01-27 08:12:45 -06:00
|
|
|
use std::collections::BTreeMap;
|
2020-08-11 08:43:21 -05:00
|
|
|
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
|
|
|
|
|
|
|
|
fn bad_foo<T: Clone + Default, Z: Copy>(arg0: T, arg1: Z)
|
|
|
|
where
|
|
|
|
T: Clone,
|
|
|
|
T: Default,
|
|
|
|
{
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn good_bar<T: Clone + Default>(arg: T) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn good_foo<T>(arg: T)
|
|
|
|
where
|
|
|
|
T: Clone + Default,
|
|
|
|
{
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn good_foobar<T: Default>(arg: T)
|
|
|
|
where
|
|
|
|
T: Clone,
|
|
|
|
{
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
2022-01-13 06:18:19 -06:00
|
|
|
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)]
|
2022-04-07 12:39:59 -05:00
|
|
|
struct Life;
|
2022-01-13 06:18:19 -06:00
|
|
|
|
|
|
|
impl T for Life {
|
|
|
|
// this should not warn
|
|
|
|
fn f() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl U for Life {
|
|
|
|
// this should not warn
|
|
|
|
fn f() {}
|
|
|
|
}
|
|
|
|
|
2022-01-27 08:12:45 -06:00
|
|
|
// should not warn
|
|
|
|
trait Iter: Iterator {
|
|
|
|
fn into_group_btreemap<K, V>(self) -> BTreeMap<K, Vec<V>>
|
|
|
|
where
|
|
|
|
Self: Iterator<Item = (K, V)> + Sized,
|
|
|
|
K: Ord + Eq,
|
|
|
|
{
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 12:39:59 -05:00
|
|
|
struct Foo;
|
2022-01-27 08:12:45 -06:00
|
|
|
|
|
|
|
trait FooIter: Iterator<Item = Foo> {
|
|
|
|
fn bar()
|
|
|
|
where
|
|
|
|
Self: Iterator<Item = Foo>,
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-05 09:12:52 -05:00
|
|
|
// This should not lint
|
|
|
|
fn impl_trait(_: impl AsRef<str>, _: impl AsRef<str>) {}
|
|
|
|
|
2022-07-18 02:39:37 -05:00
|
|
|
mod repeated_where_clauses_or_trait_bounds {
|
|
|
|
fn bad_foo<T: Clone + Clone + Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bad_bar<T, U>(arg0: T, arg1: U)
|
|
|
|
where
|
|
|
|
T: Clone + Clone + 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 + Clone + Clone {
|
|
|
|
fn f();
|
|
|
|
}
|
|
|
|
|
|
|
|
trait BadSelfWhereClause {
|
|
|
|
fn f()
|
|
|
|
where
|
|
|
|
Self: Clone + Clone + 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 + Clone + Clone + Copy, U: Clone + Copy> {
|
|
|
|
fn f();
|
|
|
|
}
|
|
|
|
|
|
|
|
trait BadWhereClause<T, U> {
|
|
|
|
fn f()
|
|
|
|
where
|
|
|
|
T: Clone + Clone + 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> {}
|
|
|
|
|
|
|
|
// This should not warn but currently does see #8757
|
|
|
|
fn good_generic<T: GenericTrait<u64> + GenericTrait<u32>>(arg0: T) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bad_generic<T: GenericTrait<u64> + GenericTrait<u32> + GenericTrait<u64>>(arg0: T) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
|
|
|
mod foo {
|
|
|
|
pub trait Clone {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn qualified_path<T: std::clone::Clone + Clone + foo::Clone>(arg0: T) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-11 08:43:21 -05:00
|
|
|
fn main() {}
|