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

type_repetition_in_bounds not always helps #4380

Closed
tspiteri opened this issue Aug 14, 2019 · 1 comment · Fixed by #5761
Closed

type_repetition_in_bounds not always helps #4380

tspiteri opened this issue Aug 14, 2019 · 1 comment · Fixed by #5761
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy

Comments

@tspiteri
Copy link
Contributor

tspiteri commented Aug 14, 2019

For a trait like this

trait LotsOfBounds
where
    Self: Clone + Copy + Default + Ord,
    Self: Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign,
    Self: Mul<Output = Self> + MulAssign + Div<Output = Self> + DivAssign,
{
}

type_repetition_in_bounds recommends combining all the traits, which would lead to either a very long line or to many many lines:

trait LotsOfBounds
where
    Self: Clone
        + Copy
        + Default
        + Ord
        + Add<Output = Self>
        + AddAssign
        + Sub<Output = Self>
        + SubAssign
        + Mul<Output = Self>
        + MulAssign
        + Div<Output = Self>
        + DivAssign
{
}

The logical grouping in the original example makes it more readable, and it is lost with the clippy suggestion.

@flip1995
Copy link
Member

flip1995 commented Aug 14, 2019

cc @xd009642

Yeah I can see your point. I see 3 options here:

  1. Leave the lint as is and users should allow it in this cases (I don't think that this would be a good solution, though)
  2. Move the lint to pedantic (I think this would be a good first step cc type_repetition_in_bounds should not trigger on macro-generated code #4326 False positive with type_repetition_in_bounds and generics #4323. I wouldn't move it to nursery though, since I think this lint is ready enough)
  3. Make the lint configurable and add a threshold of bounds, where the lint should trigger (Maybe up to 4 or 5 bounds?)

@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Aug 14, 2019
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`
@bors bors closed this as completed in fff8e72 Jul 3, 2020
@bors bors closed this as completed in #5761 Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages 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.

2 participants