Skip to content

Commit 6b6f4ce

Browse files
author
Henri Lunnikivi
committed
Improve UI test cases
1 parent 345e0a6 commit 6b6f4ce

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

tests/ui/field_reassign_with_default.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ struct B {
1111
j: i64,
1212
}
1313

14-
#[derive(Default)]
15-
struct C {
16-
i: i32,
17-
}
18-
1914
fn main() {
2015
// wrong
2116
let mut a: A = Default::default();
@@ -31,8 +26,29 @@ fn main() {
3126
};
3227

3328
// right
34-
let b = B { i: 42, j: 24 };
29+
let mut a: A = Default::default();
30+
if a.i == 0 {
31+
a.j = 12;
32+
}
33+
34+
// right
35+
let mut a: A = Default::default();
36+
let b = 5;
37+
38+
// right
39+
let mut b = 32;
40+
let mut a: A = Default::default();
41+
b = 2;
42+
43+
// right
44+
let b: B = B { i: 42, j: 24 };
45+
46+
// right
47+
let mut b: B = B { i: 42, j: 24 };
48+
b.i = 52;
3549

3650
// right
37-
let c: C = Default::default();
51+
let mut b = B { i: 15, j: 16 };
52+
let mut a: A = Default::default();
53+
b.i = 2;
3854
}

0 commit comments

Comments
 (0)