RS.CLIPPY.TRAIT_DUPLICATION_IN_BOUNDS

Check if the same trait bounds are specified more than once during a generic declaration

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: trait_duplication_in_bounds. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for cases where generics or trait objects are being used and multiple syntax specifications for trait bounds are used simultaneously.

Why is this bad?

Duplicate bounds makes the code less readable than specifying them only once.

Example

fn func<T: Clone + Default>(arg: T) where T: Clone + Default {}

Use instead:

fn func<T: Clone + Default>(arg: T) {}

// or

fn func<T>(arg: T) where T: Clone + Default {}
fn foo<T: Default + Default>(bar: T) {}

Use instead:

fn foo<T: Default>(bar: T) {}
fn foo<T>(bar: T) where T: Default + Default {}

Use instead:

fn foo<T>(bar: T) where T: Default {}