We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 69cba8c commit e2c96e9Copy full SHA for e2c96e9
compiler/rustc_error_codes/src/error_codes/E0504.md
@@ -5,25 +5,6 @@ closure.
5
6
Erroneous code example:
7
8
-```compile_fail
9
-struct FancyNum {
10
- s: String,
11
-}
12
-
13
-fn main() {
14
- let fancy_num = FancyNum { s: "".into() };
15
- let fancy_ref = &fancy_num;
16
17
- let x = move || {
18
- println!("child function: {}", fancy_num.s);
19
- // error: cannot move `fancy_num` into closure because it is borrowed
20
- };
21
22
- x();
23
- println!("main function: {}", fancy_ref.s);
24
25
-```
26
27
Here, `fancy_num` is borrowed by `fancy_ref` and so cannot be moved into
28
the closure `x`. There is no way to move a value into a closure while it is
29
borrowed, as that would invalidate the borrow.
0 commit comments