Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive with type_repetition_in_bounds and generics #4323

Closed
taiki-e opened this issue Aug 2, 2019 · 9 comments · Fixed by #5761
Closed

False positive with type_repetition_in_bounds and generics #4323

taiki-e opened this issue Aug 2, 2019 · 9 comments · Fixed by #5761
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy

Comments

@taiki-e
Copy link
Member

taiki-e commented Aug 2, 2019

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
{
}
@flip1995
Copy link
Member

flip1995 commented Aug 2, 2019

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

@flip1995 flip1995 added C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy labels Aug 2, 2019
@xd009642
Copy link
Contributor

xd009642 commented Aug 2, 2019

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

@xd009642
Copy link
Contributor

xd009642 commented Aug 4, 2019

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

@flip1995
Copy link
Member

flip1995 commented Aug 5, 2019

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

That sounds promising. Thanks for taking care of this!

bors added a commit that referenced this issue Aug 18, 2019
…h,flip1995

Improvements to `type_repetition_in_bounds`

Improvements to the `type_repetition_in_bounds` trait based on feedback from #4380 #4326 #4323

Currently just make it pedantic. Hopefully, more to come
bors added a commit that referenced this issue Aug 18, 2019
…h,flip1995

Improvements to `type_repetition_in_bounds`

Improvements to the `type_repetition_in_bounds` trait based on feedback from #4380 #4326 #4323

Currently just make it pedantic. Hopefully, more to come

changelog: move `type_repetition_in_bounds` to `pedantic`
@ThibsG
Copy link
Contributor

ThibsG commented Jul 2, 2020

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

@taiki-e
Copy link
Member Author

taiki-e commented Jul 2, 2020

I don't think this has been fixed: playground

@ThibsG
Copy link
Contributor

ThibsG commented Jul 2, 2020

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

@taiki-e
Copy link
Member Author

taiki-e commented Jul 2, 2020

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.

@ThibsG
Copy link
Contributor

ThibsG commented Jul 2, 2020

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

Note: the problem is still here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants