summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes/src/error_codes/E0301.md
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_error_codes/src/error_codes/E0301.md')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0301.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0301.md b/compiler/rustc_error_codes/src/error_codes/E0301.md
new file mode 100644
index 000000000..485e19fbb
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0301.md
@@ -0,0 +1,17 @@
+#### Note: this error code is no longer emitted by the compiler.
+
+Mutable borrows are not allowed in pattern guards, because matching cannot have
+side effects. Side effects could alter the matched object or the environment
+on which the match depends in such a way, that the match would not be
+exhaustive. For instance, the following would not match any arm if mutable
+borrows were allowed:
+
+```compile_fail,E0596
+match Some(()) {
+ None => { },
+ option if option.take().is_none() => {
+ /* impossible, option is `Some` */
+ },
+ Some(_) => { } // When the previous match failed, the option became `None`.
+}
+```