@@ -5,20 +5,43 @@ LL | Enum::A(_) if { x = Enum::B(false); false } => 1,
55 | ^^^^^^^^^^^^^^^^^^ assignment in pattern guard
66
77error[E0301]: cannot mutably borrow in a pattern guard
8- --> $DIR/borrowck-mutate-in-guard.rs:12 :38
8+ --> $DIR/borrowck-mutate-in-guard.rs:15 :38
99 |
1010LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
1111 | ^ borrowed mutably in pattern guard
1212 |
1313 = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable
1414
1515error[E0302]: cannot assign in a pattern guard
16- --> $DIR/borrowck-mutate-in-guard.rs:12 :41
16+ --> $DIR/borrowck-mutate-in-guard.rs:15 :41
1717 |
1818LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
1919 | ^^^^^^^^^^^^^^^^^^^ assignment in pattern guard
2020
21+ warning[E0510]: cannot assign `x` in match guard
22+ --> $DIR/borrowck-mutate-in-guard.rs:10:25
23+ |
24+ LL | match x {
25+ | - value is immutable in match guard
26+ LL | Enum::A(_) if { x = Enum::B(false); false } => 1,
27+ | ^^^^^^^^^^^^^^^^^^ cannot assign
28+ |
29+ = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
30+ = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
31+
32+ warning[E0510]: cannot mutably borrow `x` in match guard
33+ --> $DIR/borrowck-mutate-in-guard.rs:15:33
34+ |
35+ LL | match x {
36+ | - value is immutable in match guard
37+ ...
38+ LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
39+ | ^^^^^^ cannot mutably borrow
40+ |
41+ = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
42+ = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
43+
2144error: aborting due to 3 previous errors
2245
23- Some errors have detailed explanations: E0301, E0302.
46+ Some errors have detailed explanations: E0301, E0302, E0510 .
2447For more information about an error, try `rustc --explain E0301`.
0 commit comments