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

trait_duplication_in_bounds lint has misleading message #9151

Closed
aldhsu opened this issue Jul 11, 2022 · 0 comments
Closed

trait_duplication_in_bounds lint has misleading message #9151

aldhsu opened this issue Jul 11, 2022 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@aldhsu
Copy link
Contributor

aldhsu commented Jul 11, 2022

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

@aldhsu aldhsu added the C-bug Category: Clippy is not doing the correct thing label Jul 11, 2022
@aldhsu aldhsu changed the title trait_duplication_in_bounds lint doesn't consider generics trait_duplication_in_bounds lint has misleading message Jul 11, 2022
aldhsu added a commit to aldhsu/rust-clippy that referenced this issue Jul 12, 2022
- only compare where predicates to trait bounds when generating where
  clause specific message to fix rust-lang#9151
- use comparable_trait_ref to account for trait bound generics to fix rust-lang#8757
aldhsu added a commit to aldhsu/rust-clippy that referenced this issue Jul 13, 2022
- only compare where predicates to trait bounds when generating where
  clause specific message to fix rust-lang#9151
- use comparable_trait_ref to account for trait bound generics to fix rust-lang#8757
aldhsu added a commit to aldhsu/rust-clippy that referenced this issue Jul 13, 2022
- only compare where predicates to trait bounds when generating where
  clause specific message to fix rust-lang#9151
- use comparable_trait_ref to account for trait bound generics to fix rust-lang#8757
bors added a commit that referenced this issue Aug 14, 2022
Fixes [`trait_duplication_in_bounds`] false positives

Fixes #9076 #9151 #8757.
Partially fixes #8771.

changelog: [`trait_duplication_in_bounds`]: Reduce number of false positives.
@bors bors closed this as completed in 171d082 Aug 14, 2022
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
Projects
None yet
Development

No branches or pull requests

1 participant