]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
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 | |
416331ca | 12 | //~| ERROR cannot assign `x` in match guard |
1a4d82fc JJ |
13 | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, |
14 | //~^ ERROR cannot mutably borrow in a pattern guard | |
48663c56 | 15 | //~| ERROR cannot assign in a pattern guard |
416331ca | 16 | //~| ERROR cannot mutably borrow `x` in match guard |
1a4d82fc JJ |
17 | Enum::A(p) => *p, |
18 | Enum::B(_) => 2, | |
19 | } | |
20 | } | |
21 | ||
22 | fn main() { | |
23 | foo(); | |
24 | } |