Skip to content

False positive from type_repetition_in_bounds #5839

Closed
@eopb

Description

@eopb

I tried this code:

use std::collections::HashMap;

trait Example {}

struct Map<K, V>(HashMap<K, V>);

impl<K, V> Map<K, V>
where
    HashMap<K, V>: Clone,
    HashMap<String, V>: Example,
{
}

I get the warning

warning: this type has already been used as a bound predicate
  --> src/main.rs:14:5
   |
14 |     HashMap<String, V>: Example,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `-W clippy::type-repetition-in-bounds` implied by `-W clippy::pedantic`
   = help: consider combining the bounds: `HashMap<String, V>: Clone + Example`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds

HashMap<K, V> and HashMap<String, V> are different types so this lint should not show.

Meta

  • cargo clippy -V: clippy 0.0.212 (346aec9 2020-07-11)
  • rustc -Vv:
rustc 1.46.0-nightly (346aec9b0 2020-07-11)
binary: rustc
commit-hash: 346aec9b02f3c74f3fce97fd6bda24709d220e49
commit-date: 2020-07-11
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0

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