Skip to content

type_repetition_in_bounds + trait_duplication_in_bounds false positive on signature containing double impl Trait #8771

@dtolnay

Description

@dtolnay

Summary

Clippy makes a suggestion to write impl Trait: Trait + Trait which does not make sense.

Lint Name

type_repetition_in_bounds and trait_duplication_in_bounds

Reproducer

pub trait Trait {}

pub fn f(_a: impl Trait, _b: impl Trait) {}
error: this type has already been used as a bound predicate
 --> src/main.rs:3:35
  |
3 | pub fn f(_a: impl Trait, _b: impl Trait) {}
  |                                   ^^^^^
  |
  = note: `-D clippy::type-repetition-in-bounds` implied by `-D clippy::pedantic`
  = help: consider combining the bounds: `impl Trait: Trait + Trait`
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

error: this trait bound is already specified in the where clause
 --> src/main.rs:3:19
  |
3 | pub fn f(_a: impl Trait, _b: impl Trait) {}
  |                   ^^^^^
  |
  = note: `-D clippy::trait-duplication-in-bounds` implied by `-D clippy::pedantic`
  = help: consider removing this trait bound
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trait_duplication_in_bounds

Version

rustc 1.62.0-nightly (7c4b47696 2022-04-30)
binary: rustc
commit-hash: 7c4b47696907d64eff5621a64eb3c6e795a9ec77
commit-date: 2022-04-30
host: x86_64-unknown-linux-gnu
release: 1.62.0-nightly
LLVM version: 14.0.1

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions