]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/src/docs/derivable_impls.txt
New upstream version 1.66.0+dfsg1
[rustc.git] / src / tools / clippy / src / docs / derivable_impls.txt
1 ### What it does
2 Detects manual `std::default::Default` implementations that are identical to a derived implementation.
3
4 ### Why is this bad?
5 It is less concise.
6
7 ### Example
8 ```
9 struct Foo {
10 bar: bool
11 }
12
13 impl Default for Foo {
14 fn default() -> Self {
15 Self {
16 bar: false
17 }
18 }
19 }
20 ```
21
22 Use instead:
23 ```
24 #[derive(Default)]
25 struct Foo {
26 bar: bool
27 }
28 ```
29
30 ### Known problems
31 Derive macros [sometimes use incorrect bounds](https://github.com/rust-lang/rust/issues/26925)
32 in generic types and the user defined `impl` may be more generalized or
33 specialized than what derive will produce. This lint can't detect the manual `impl`
34 has exactly equal bounds, and therefore this lint is disabled for types with
35 generic parameters.