Rust-clippy: False positive with type_repetition_in_bounds and generics

Created on 2 Aug 2019  路  9Comments  路  Source: rust-lang/rust-clippy

type_repetition_in_bounds seems missed generics in types.

#![allow(dead_code)]
#![warn(clippy::type_repetition_in_bounds)]

pub struct Foo<A>(A);

pub struct Bar<A, B> {
    a: Foo<A>,
    b: Foo<B>,
}

impl<A, B> Unpin for Bar<A, B>
where
    Foo<A>: Unpin,
    Foo<B>: Unpin, //~ WARN this type has already been used as a bound predicate
{
}
L-bug good-first-issue

All 9 comments

cc @xd009642 Any idea why this happens? Seems like the hashing of the types is missing the generics.

I'll have a look tonight but that seems the most likely scenario

So I can't see any parameters in Ty or TyKind for generic types associated with the type. There's 1rustc::hir::WhereBoundPredicate::bounded_generic_params` which maybe should be hashed? Provided that it's just the generics used in each bounded type. I'll have a play and see what I can do

rustc::hir::WhereBoundPredicate::bounded_generic_params which maybe should be hashed

That sounds promising. Thanks for taking care of this!

I cannot reproduce this warning. Am I doing something wrong or the issue has gone?

I don't think this has been fixed: playground

Indeed, I cannot trigger this on my local Clippy test, I will figure out why

I cannot trigger this on my local Clippy test

I guess it's one of the following:

  • compiletest may ignore the warning, so you might be able to reproduce this by using #![deny(...)] instead of #![warn(...)].
  • This has been fixed in the master but not yet released.

Yes I just fixed it, something went wrong with deny/warn and my eyes.

Note: the problem is still here.

Was this page helpful?
0 / 5 - 0 ratings