We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 345e0a6 commit 6b6f4ceCopy full SHA for 6b6f4ce
tests/ui/field_reassign_with_default.rs
@@ -11,11 +11,6 @@ struct B {
11
j: i64,
12
}
13
14
-#[derive(Default)]
15
-struct C {
16
- i: i32,
17
-}
18
-
19
fn main() {
20
// wrong
21
let mut a: A = Default::default();
@@ -31,8 +26,29 @@ fn main() {
31
26
};
32
27
33
28
// right
34
- let b = B { i: 42, j: 24 };
29
+ let mut a: A = Default::default();
30
+ if a.i == 0 {
+ a.j = 12;
+ }
+
+ // right
35
36
+ let b = 5;
37
38
39
+ let mut b = 32;
40
41
+ b = 2;
42
43
44
+ let b: B = B { i: 42, j: 24 };
45
46
47
+ let mut b: B = B { i: 42, j: 24 };
48
+ b.i = 52;
49
50
- let c: C = Default::default();
51
+ let mut b = B { i: 15, j: 16 };
52
53
+ b.i = 2;
54
0 commit comments