rust-lang / rust-lang/rust-clippy
Suggest trait implementations for references/boxes
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Sort of an awkward way to word this, but it'll make a bit more sense with an explanation.
Right now, there are implementations for &T + T, T + &T, and T += &T for integer types. There should be some nice list of traits where there should be suggestions to add implementations for references as well.
Just off the top of my head:
Add, etc. should haveAdd<&U> for TandAdd<U> for &TifAdd<U> for Tis available.AddAssign, etc. should haveAddAssign<&U> for TifAddAssign<U> for Tis available.Sum, etc. should haveSum for &TifSum for Tis available.
There may be a way to detect a list of traits where an impl for T should suggest an impl for &T, &mut T, and Box<T> as well, like Hasher and Debug. I'm not sure how we could suggest which traits work for this, but I figured I'd add it to the discussion.
These "convenience" impls are nice to have and there are a lot of cases where these are added to the standard library when they are forgotten. It'd be nice if we could suggest them via clippy.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file, test, or entry point is named. Start by reviewing the existing reference implementations for Add, AddAssign, and Sum, then compare the possible Hasher and Debug cases mentioned in the issue. Done would require a decided, maintainable rule for which reference, mutable-reference, and Box implementations Clippy should suggest.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100