]> git.lizzy.rs Git - rust.git/blobdiff - src/test/ui/borrowck/borrowck-mutate-in-guard.stderr
Add FAQ for NLL migration
[rust.git] / src / test / ui / borrowck / borrowck-mutate-in-guard.stderr
index 9e40856deb0316d9803055f8507219a4e96071ac..ac6bed6137fa304577dd009cb862b0e3cf908be8 100644 (file)
@@ -5,18 +5,45 @@ LL |         Enum::A(_) if { x = Enum::B(false); false } => 1,
    |                         ^^^^^^^^^^^^^^^^^^ assignment in pattern guard
 
 error[E0301]: cannot mutably borrow in a pattern guard
-  --> $DIR/borrowck-mutate-in-guard.rs:12:38
+  --> $DIR/borrowck-mutate-in-guard.rs:15:38
    |
 LL |         Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
    |                                      ^ borrowed mutably in pattern guard
+   |
+   = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable
 
 error[E0302]: cannot assign in a pattern guard
-  --> $DIR/borrowck-mutate-in-guard.rs:12:41
+  --> $DIR/borrowck-mutate-in-guard.rs:15:41
    |
 LL |         Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
    |                                         ^^^^^^^^^^^^^^^^^^^ assignment in pattern guard
 
+warning[E0510]: cannot assign `x` in match guard
+  --> $DIR/borrowck-mutate-in-guard.rs:10:25
+   |
+LL |     match x {
+   |           - value is immutable in match guard
+LL |         Enum::A(_) if { x = Enum::B(false); false } => 1,
+   |                         ^^^^^^^^^^^^^^^^^^ cannot assign
+   |
+   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
+   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
+   = note: for more information, try `rustc --explain E0729`
+
+warning[E0510]: cannot mutably borrow `x` in match guard
+  --> $DIR/borrowck-mutate-in-guard.rs:15:33
+   |
+LL |     match x {
+   |           - value is immutable in match guard
+...
+LL |         Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1,
+   |                                 ^^^^^^ cannot mutably borrow
+   |
+   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
+   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
+   = note: for more information, try `rustc --explain E0729`
+
 error: aborting due to 3 previous errors
 
-Some errors occurred: E0301, E0302.
+Some errors have detailed explanations: E0301, E0302, E0510.
 For more information about an error, try `rustc --explain E0301`.