]> git.proxmox.com Git - rustc.git/blob - src/test/ui/borrowck/or-patterns.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / borrowck / or-patterns.rs
1 // Test that borrow check considers all choices in an or pattern, even the
2 // unreachable ones.
3
4 fn or_pattern_moves_all(x: ((String, String),)) {
5 match x {
6 ((y, _) | (_, y),) => (),
7 }
8 &x.0 .0;
9 //~^ ERROR borrow of moved value
10 &x.0 .1;
11 //~^ ERROR borrow of moved value
12 }
13
14 fn or_pattern_borrows_all(mut x: ((String, String),)) {
15 let r = match x {
16 ((ref y, _) | (_, ref y),) => y,
17 };
18 &mut x.0 .0;
19 //~^ ERROR cannot borrow
20 &mut x.0 .1;
21 //~^ ERROR cannot borrow
22 drop(r);
23 }
24
25 fn or_pattern_borrows_all_mut(mut x: ((String, String),)) {
26 let r = match x {
27 ((ref mut y, _) | (_, ref mut y),) => y,
28 };
29 &x.0 .0;
30 //~^ ERROR cannot borrow
31 &x.0 .1;
32 //~^ ERROR cannot borrow
33 drop(r);
34 }
35
36 fn let_or_pattern_moves_all(x: ((String, String),)) {
37 let ((y, _) | (_, y),) = x;
38 &x.0 .0;
39 //~^ ERROR borrow of moved value
40 &x.0 .1;
41 //~^ ERROR borrow of moved value
42 }
43
44 fn let_or_pattern_borrows_all(mut x: ((String, String),)) {
45 let ((ref r, _) | (_, ref r),) = x;
46 &mut x.0 .0;
47 //~^ ERROR cannot borrow
48 &mut x.0 .1;
49 //~^ ERROR cannot borrow
50 drop(r);
51 }
52
53 fn let_or_pattern_borrows_all_mut(mut x: ((String, String),)) {
54 let ((ref mut r, _) | (_, ref mut r),) = x;
55 &x.0 .0;
56 //~^ ERROR cannot borrow
57 &x.0 .1;
58 //~^ ERROR cannot borrow
59 drop(r);
60 }
61
62 fn main() {}