]> git.lizzy.rs Git - rust.git/commitdiff
Clean up E0501 explanation
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Thu, 2 Apr 2020 11:30:19 +0000 (13:30 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 6 Apr 2020 16:12:42 +0000 (18:12 +0200)
src/librustc_error_codes/error_codes/E0501.md

index f5aa17a809467cb171f6060c0a266aa44f79d261..ffdbc443905ae44aa3f191add7c5b3335ae5adc0 100644 (file)
@@ -1,12 +1,4 @@
-This error indicates that a mutable variable is being used while it is still
-captured by a closure. Because the closure has borrowed the variable, it is not
-available for use until the closure goes out of scope.
-
-Note that a capture will either move or borrow a variable, but in this
-situation, the closure is borrowing the variable. Take a look at the chapter
-on [Capturing][capturing] in Rust By Example for more information.
-
-[capturing]: https://doc.rust-lang.org/stable/rust-by-example/fn/closures/capture.html
+A mutable variable is used but it is already captured by a closure.
 
 Erroneous code example:
 
@@ -29,6 +21,16 @@ fn foo(a: &mut i32) {
 }
 ```
 
+This error indicates that a mutable variable is used while it is still captured
+by a closure. Because the closure has borrowed the variable, it is not available
+until the closure goes out of scope.
+
+Note that a capture will either move or borrow a variable, but in this
+situation, the closure is borrowing the variable. Take a look at the chapter
+on [Capturing][capturing] in Rust By Example for more information.
+
+[capturing]: https://doc.rust-lang.org/stable/rust-by-example/fn/closures/capture.html
+
 To fix this error, you can finish using the closure before using the captured
 variable: