about summary refs log tree commit diff
path: root/src/librustc_error_codes/error_codes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-04-08 17:55:45 +0000
committerbors <bors@rust-lang.org>2020-04-08 17:55:45 +0000
commit485c5fb6e1bf12cd11a8fac5ee94962e17cff74b (patch)
treea576971dc9a95edc00323856e06505ee4dae5b00 /src/librustc_error_codes/error_codes
parent42abbd8878d3b67238f3611b0587c704ba94f39c (diff)
parent1498da87c274508f33aa878e39a8faa3659a4121 (diff)
downloadrust-485c5fb6e1bf12cd11a8fac5ee94962e17cff74b.tar.gz
rust-485c5fb6e1bf12cd11a8fac5ee94962e17cff74b.zip
Auto merge of #70931 - Dylan-DPC:rollup-f8orcao, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #70789 (remove false positives of unused_braces)
 - #70847 (ci: move /var/lib/docker to /mnt on GHA)
 - #70850 (BTreeMap first last proposal tweaks)
 - #70876 (Use a `SmallVec` for `Cache::predecessors`.)
 - #70883 (Clean up E0507 explanation)
 - #70892 (wf: refactor `compute_trait_ref`)
 - #70914 (Corrects a typo in rustdoc documentation.)
 - #70915 (Remove unnecessary TypeFlags::NOMINAL_FLAGS)
 - #70927 (Clean up E0510 explanation)

Failed merges:

r? @ghost
Diffstat (limited to 'src/librustc_error_codes/error_codes')
-rw-r--r--src/librustc_error_codes/error_codes/E0507.md12
-rw-r--r--src/librustc_error_codes/error_codes/E0510.md27
2 files changed, 26 insertions, 13 deletions
diff --git a/src/librustc_error_codes/error_codes/E0507.md b/src/librustc_error_codes/error_codes/E0507.md
index 1e3457e96c5..254751fc45e 100644
--- a/src/librustc_error_codes/error_codes/E0507.md
+++ b/src/librustc_error_codes/error_codes/E0507.md
@@ -1,9 +1,4 @@
-You tried to move out of a value which was borrowed.
-
-This can also happen when using a type implementing `Fn` or `FnMut`, as neither
-allows moving out of them (they usually represent closures which can be called
-more than once). Much of the text following applies equally well to non-`FnOnce`
-closure bodies.
+A borrowed value was moved out.
 
 Erroneous code example:
 
@@ -32,6 +27,11 @@ you have three choices:
 * Somehow reclaim the ownership.
 * Implement the `Copy` trait on the type.
 
+This can also happen when using a type implementing `Fn` or `FnMut`, as neither
+allows moving out of them (they usually represent closures which can be called
+more than once). Much of the text following applies equally well to non-`FnOnce`
+closure bodies.
+
 Examples:
 
 ```
diff --git a/src/librustc_error_codes/error_codes/E0510.md b/src/librustc_error_codes/error_codes/E0510.md
index d5be417888b..e045e04bdbe 100644
--- a/src/librustc_error_codes/error_codes/E0510.md
+++ b/src/librustc_error_codes/error_codes/E0510.md
@@ -1,16 +1,29 @@
-Cannot mutate place in this match guard.
+The matched value was assigned in a match guard.
 
-When matching on a variable it cannot be mutated in the match guards, as this
-could cause the match to be non-exhaustive:
+Erroneous code example:
 
 ```compile_fail,E0510
 let mut x = Some(0);
 match x {
-    None => (),
-    Some(_) if { x = None; false } => (),
-    Some(v) => (), // No longer matches
+    None => {}
+    Some(_) if { x = None; false } => {} // error!
+    Some(_) => {}
 }
 ```
 
+When matching on a variable it cannot be mutated in the match guards, as this
+could cause the match to be non-exhaustive.
+
 Here executing `x = None` would modify the value being matched and require us
-to go "back in time" to the `None` arm.
+to go "back in time" to the `None` arm. To fix it, change the value in the match
+arm:
+
+```
+let mut x = Some(0);
+match x {
+    None => {}
+    Some(_) => {
+        x = None; // ok!
+    }
+}
+```