]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/borrowck/or-patterns.rs
1 // Test that borrow check considers all choices in an or pattern, even the
4 fn or_pattern_moves_all(x
: ((String
, String
),)) {
6 ((y
, _
) | (_
, y
),) => (),
9 //~^ ERROR borrow of moved value
11 //~^ ERROR borrow of moved value
14 fn or_pattern_borrows_all(mut x
: ((String
, String
),)) {
16 ((ref y
, _
) | (_
, ref y
),) => y
,
19 //~^ ERROR cannot borrow
21 //~^ ERROR cannot borrow
25 fn or_pattern_borrows_all_mut(mut x
: ((String
, String
),)) {
27 ((ref mut y
, _
) | (_
, ref mut y
),) => y
,
30 //~^ ERROR cannot borrow
32 //~^ ERROR cannot borrow
36 fn let_or_pattern_moves_all(x
: ((String
, String
),)) {
37 let ((y
, _
) | (_
, y
),) = x
;
39 //~^ ERROR borrow of moved value
41 //~^ ERROR borrow of moved value
44 fn let_or_pattern_borrows_all(mut x
: ((String
, String
),)) {
45 let ((ref r
, _
) | (_
, ref r
),) = x
;
47 //~^ ERROR cannot borrow
49 //~^ ERROR cannot borrow
53 fn let_or_pattern_borrows_all_mut(mut x
: ((String
, String
),)) {
54 let ((ref mut r
, _
) | (_
, ref mut r
),) = x
;
56 //~^ ERROR cannot borrow
58 //~^ ERROR cannot borrow