Skip to content

trait_duplication_in_bounds lint has misleading message #9151

@aldhsu

Description

@aldhsu

Summary

TRAIT_DUPLICATION_IN_BOUNDS lint.
Trait duplications within bounds raises a lint that refers to where clauses that don't exist.

Reproducer

I tried this code:

fn duplicate_trait<T: Clone + Clone + Default, Z: Copy>(arg0: T, arg1: Z) {}

I expected to see this happen:
The error message to warn about trait duplication within bounds or alternatively no error.

Instead, this happened:

error: this trait bound is already specified in the where clause
  --> $DIR/trait_duplication_in_bounds.rs:110:16
   |
LL | fn duplicate_trait<T: Clone + Clone + Default, Z: Copy>(arg0: T, arg1: Z) {}
   |                       ^^^^^
   |
   = help: consider removing this trait bound

Error refers to a where clause that doesn't exist.

Version

rustc 1.62.0-nightly (8f36334ca 2022-04-06)
binary: rustc
commit-hash: 8f36334ca939a67cce3f37f24953ff6f2d3f3d33
commit-date: 2022-04-06
host: x86_64-apple-darwin
release: 1.62.0-nightly
LLVM version: 14.0.0

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions