]> git.proxmox.com Git - rustc.git/blob - src/test/ui/borrowck/borrowck-mutate-in-guard.rs
New upstream version 1.38.0+dfsg1
[rustc.git] / src / test / ui / borrowck / borrowck-mutate-in-guard.rs
1 enum Enum<'a> {
2 A(&'a isize),
3 B(bool),
4 }
5
6 fn foo() -> isize {
7 let mut n = 42;
8 let mut x = Enum::A(&mut n);
9 match x {
10 Enum::A(_) if { x = Enum::B(false); false } => 1,
11 //~^ ERROR cannot assign in a pattern guard
12 //~| ERROR cannot assign `x` in match guard
13 Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
14 //~^ ERROR cannot mutably borrow in a pattern guard
15 //~| ERROR cannot assign in a pattern guard
16 //~| ERROR cannot mutably borrow `x` in match guard
17 Enum::A(p) => *p,
18 Enum::B(_) => 2,
19 }
20 }
21
22 fn main() {
23 foo();
24 }