blob: fba2873fd02a3a1aa644fd79462b8dd65f6002b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#![feature(deref_patterns)]
#![allow(incomplete_features)]
#[rustfmt::skip]
fn main() {
let mut v = vec![false];
match v {
deref!([true]) => {}
_ if { v[0] = true; false } => {}
//~^ ERROR cannot borrow `v` as mutable because it is also borrowed as immutable
deref!([false]) => {}
_ => {},
}
match v {
[true] => {}
_ if { v[0] = true; false } => {}
//~^ ERROR cannot borrow `v` as mutable because it is also borrowed as immutable
[false] => {}
_ => {},
}
// deref patterns on boxes are lowered specially; test them separately.
let mut b = Box::new(false);
match b {
deref!(true) => {}
_ if { *b = true; false } => {}
//~^ ERROR cannot assign `*b` in match guard
deref!(false) => {}
_ => {},
}
match b {
true => {}
_ if { *b = true; false } => {}
//~^ ERROR cannot assign `*b` in match guard
false => {}
_ => {},
}
}
|