You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that associated type bounds are stabilized, I'd love to have a clippy lint (ideally with machine-applicable fix) that catches cases that could be written using associated type bounds.
This could start with the simplest cases:
if a set of bounds contains a trait with an associated type, and has the form T: TraitWithAssoc, <T as TraitWithAssoc>::Assoc: Bound, lint with a suggestion to merge into T: TraitWithAssoc<Assoc: Bound>.
if a set of bounds contains a trait with an associated type, and has the form T: TraitWithassoc<Assoc = U>, U: Bound, and U isn't used for anything else, lint with a suggestion to merge into T: TraitWithAssoc<Assoc: Bound> and delete the declaration of U.
Advantage
This simplifies bounds and makes them easier to follow, with less indirection. In some cases it also eliminates the need for the complex <T as TraitWithAssoc>::Assoc syntax.
What it does
Now that associated type bounds are stabilized, I'd love to have a clippy lint (ideally with machine-applicable fix) that catches cases that could be written using associated type bounds.
This could start with the simplest cases:
T: TraitWithAssoc, <T as TraitWithAssoc>::Assoc: Bound
, lint with a suggestion to merge intoT: TraitWithAssoc<Assoc: Bound>
.T: TraitWithassoc<Assoc = U>, U: Bound
, andU
isn't used for anything else, lint with a suggestion to merge intoT: TraitWithAssoc<Assoc: Bound>
and delete the declaration ofU
.Advantage
This simplifies bounds and makes them easier to follow, with less indirection. In some cases it also eliminates the need for the complex
<T as TraitWithAssoc>::Assoc
syntax.Drawbacks
No response
Example
Could be written as:
The text was updated successfully, but these errors were encountered: