]> git.proxmox.com Git - rustc.git/blob - src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs
New upstream version 1.31.0~beta.4+dfsg1
[rustc.git] / src / test / ui / borrowck / issue-54499-field-mutation-marks-mut-as-used.rs
1 // revisions: ast nll
2
3 // Since we are testing nll migration explicitly as a separate
4 // revision, don't worry about the --compare-mode=nll on this test.
5
6 // ignore-compare-mode-nll
7
8 //[ast]compile-flags: -Z borrowck=ast
9 //[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
10
11 #![warn(unused)]
12 #[derive(Debug)]
13 struct S(i32);
14
15 type Tuple = (S, i32);
16 struct Tpair(S, i32);
17 struct Spair { x: S, y: i32 }
18
19 fn main() {
20 {
21 let mut t: Tuple;
22 t.0 = S(1);
23 //[nll]~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381]
24 t.1 = 2;
25 println!("{:?} {:?}", t.0, t.1);
26 //[ast]~^ ERROR use of possibly uninitialized variable: `t.0` [E0381]
27 //[ast]~| ERROR use of possibly uninitialized variable: `t.1` [E0381]
28 }
29
30 {
31 let mut u: Tpair;
32 u.0 = S(1);
33 //[nll]~^ ERROR assign to part of possibly uninitialized variable: `u` [E0381]
34 u.1 = 2;
35 println!("{:?} {:?}", u.0, u.1);
36 //[ast]~^ ERROR use of possibly uninitialized variable: `u.0` [E0381]
37 //[ast]~| ERROR use of possibly uninitialized variable: `u.1` [E0381]
38 }
39
40 {
41 let mut v: Spair;
42 v.x = S(1);
43 //[nll]~^ ERROR assign to part of possibly uninitialized variable: `v` [E0381]
44 v.y = 2;
45 println!("{:?} {:?}", v.x, v.y);
46 //[ast]~^ ERROR use of possibly uninitialized variable: `v.x` [E0381]
47 //[ast]~| ERROR use of possibly uninitialized variable: `v.y` [E0381]
48 }
49 }