What it does
Suggestion: Add a lint (let's call it suggest_derive) and configuration option (let's call it suggestable_derives). The user sets suggestable_derives to a list of derivable traits, and then whenever clippy finds a type that could derive one of those traits but doesn't, a warning is emitted.
Advantage
No response
Drawbacks
- If
Copy is included in suggestable_derives, care must be taken to not give conflicting advice with the copy_iterator lint.
Example
With the following config:
suggestable_derives = ["Clone", "Debug", "Eq", "PartialEq"]
This code:
#[derive(Debug)]
struct Foo {
name: String,
size: usize,
}
Could be written as:
#[derive(Clone, Debug, Eq, PartialEq)]
struct Foo {
name: String,
size: usize,
}
Comparison with existing lints
No response
Additional Context
No response