We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 578960d commit 247e0b5Copy full SHA for 247e0b5
tests/ui/field_reassign_with_default.rs
@@ -0,0 +1,38 @@
1
+#![warn(clippy::field_reassign_with_default)]
2
+
3
+#[derive(Default)]
4
+struct A {
5
+ i: i32,
6
+ j: i64,
7
+}
8
9
+struct B {
10
11
12
13
14
15
+struct C {
16
17
18
19
+fn main() {
20
+ // wrong
21
+ let mut a: A = Default::default();
22
+ a.i = 42;
23
24
+ // right
25
26
27
28
+ let a = A {
29
+ i: 42,
30
+ ..Default::default()
31
+ };
32
33
34
+ let b = B { i: 42, j: 24 };
35
36
37
+ let c: C = Default::default();
38
0 commit comments