#![warn(clippy::implied_bounds_in_impl)] #![allow(dead_code)] use std::ops::{Deref, DerefMut}; // Only one bound, nothing to lint. fn normal_deref(x: T) -> impl Deref { Box::new(x) } // Deref implied by DerefMut fn deref_derefmut(x: T) -> impl Deref + DerefMut { Box::new(x) } trait GenericTrait {} trait GenericTrait2 {} // U is intentionally at a different "index" in GenericSubtrait than `T` is in GenericTrait trait GenericSubtrait: GenericTrait + GenericTrait2 {} impl GenericTrait for () {} impl GenericTrait for () {} impl GenericTrait2 for () {} impl GenericSubtrait<(), i32, V> for () {} impl GenericSubtrait<(), i64, V> for () {} fn generics_implied() -> impl GenericTrait + GenericSubtrait<(), T, ()> where (): GenericSubtrait<(), T, ()>, { } fn generics_implied_multi() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), i32, V> {} fn generics_implied_multi2() -> impl GenericTrait + GenericTrait2 + GenericSubtrait<(), T, V> where (): GenericSubtrait<(), T, V> + GenericTrait, { } // i32 != i64, GenericSubtrait<_, i64, _> does not imply GenericTrait, don't lint fn generics_different() -> impl GenericTrait + GenericSubtrait<(), i64, ()> {} // i32 == i32, GenericSubtrait<_, i32, _> does imply GenericTrait, lint fn generics_same() -> impl GenericTrait + GenericSubtrait<(), i32, ()> {} fn main() {}