#![deny(clippy::type_repetition_in_bounds)] #![allow(clippy::extra_unused_type_parameters)] use serde::Deserialize; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; pub fn foo(_t: T) where T: Copy, T: Clone, //~^ ERROR: this type has already been used as a bound predicate { unimplemented!(); } pub fn bar(_t: T, _u: U) where T: Copy, U: Clone, { unimplemented!(); } // Threshold test (see #4380) trait LintBounds where Self: Clone, Self: Copy + Default + Ord, //~^ ERROR: this type has already been used as a bound predicate Self: Add + AddAssign + Sub + SubAssign, Self: Mul + MulAssign + Div + DivAssign, { } trait LotsOfBounds where Self: Clone + Copy + Default + Ord, Self: Add + AddAssign + Sub + SubAssign, Self: Mul + MulAssign + Div + DivAssign, { } // Generic distinction (see #4323) mod issue4323 { pub struct Foo(A); pub struct Bar { a: Foo, b: Foo, } impl Unpin for Bar where Foo: Unpin, Foo: Unpin, { } } // Extern macros shouldn't lint (see #4326) extern crate serde; mod issue4326 { use serde::{Deserialize, Serialize}; trait Foo {} impl Foo for String {} #[derive(Debug, Serialize, Deserialize)] struct Bar where S: Foo, { foo: S, } } // Extern macros shouldn't lint, again (see #10504) mod issue10504 { use serde::{Deserialize, Serialize}; use std::fmt::Debug; use std::hash::Hash; #[derive(Debug, Serialize, Deserialize)] #[serde(bound( serialize = "T: Serialize + Hash + Eq", deserialize = "Box: serde::de::DeserializeOwned + Hash + Eq" ))] struct OpaqueParams(std::marker::PhantomData); } // Issue #7360 struct Foo where T: Clone, U: Clone, { t: T, u: U, } // Check for the `?` in `?Sized` pub fn f() where T: Clone, //~^ ERROR: this type has already been used as a bound predicate { } pub fn g() where T: ?Sized, //~^ ERROR: this type has already been used as a bound predicate { } // This should not lint fn impl_trait(_: impl AsRef, _: impl AsRef) {} #[clippy::msrv = "1.14.0"] mod issue8772_fail { pub trait Trait {} pub fn f(arg: usize) where T: Trait, Box<[String]>, bool> + 'static, U: Clone + Sync + 'static, { } } #[clippy::msrv = "1.15.0"] mod issue8772_pass { pub trait Trait {} pub fn f(arg: usize) where T: Trait, Box<[String]>, bool> + 'static, //~^ ERROR: this type has already been used as a bound predicate U: Clone + Sync + 'static, { } } fn main() {}