]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-anon-fields-tuple.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-anon-fields-tuple.rs
1 // Tests that we are able to distinguish when loans borrow different
2 // anonymous fields of a tuple vs the same anonymous field.
3
4 fn distinct_variant() {
5     let mut y = (1, 2);
6
7     let a = match y {
8         (ref mut a, _) => a
9     };
10
11     let b = match y {
12         (_, ref mut b) => b
13     };
14
15     *a += 1;
16     *b += 1;
17 }
18
19 fn same_variant() {
20     let mut y = (1, 2);
21
22     let a = match y {
23         (ref mut a, _) => a
24     };
25
26     let b = match y {
27         (ref mut b, _) => b //~ ERROR cannot borrow
28     };
29
30     *a += 1;
31     *b += 1;
32 }
33
34 fn main() {
35 }