Skip to content

type_repetition_in_bounds not always helps #4380

Closed
@tspiteri

Description

@tspiteri

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions