File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change 1- This error indicates that a mutable variable is being used while it is still
2- captured by a closure. Because the closure has borrowed the variable, it is not
3- available for use until the closure goes out of scope.
4-
5- Note that a capture will either move or borrow a variable, but in this
6- situation, the closure is borrowing the variable. Take a look at the chapter
7- on [ Capturing] [ capturing ] in Rust By Example for more information.
8-
9- [ capturing ] : https://doc.rust-lang.org/stable/rust-by-example/fn/closures/capture.html
1+ A mutable variable is used but it is already captured by a closure.
102
113Erroneous code example:
124
@@ -29,6 +21,16 @@ fn foo(a: &mut i32) {
2921}
3022```
3123
24+ This error indicates that a mutable variable is used while it is still captured
25+ by a closure. Because the closure has borrowed the variable, it is not available
26+ until the closure goes out of scope.
27+
28+ Note that a capture will either move or borrow a variable, but in this
29+ situation, the closure is borrowing the variable. Take a look at the chapter
30+ on [ Capturing] [ capturing ] in Rust By Example for more information.
31+
32+ [ capturing ] : https://doc.rust-lang.org/stable/rust-by-example/fn/closures/capture.html
33+
3234To fix this error, you can finish using the closure before using the captured
3335variable:
3436
You can’t perform that action at this time.
0 commit comments