]> git.proxmox.com Git - rustc.git/blame - src/test/ui/borrowck/borrowck-escaping-closure-error-1.stderr
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / borrowck / borrowck-escaping-closure-error-1.stderr
CommitLineData
ff7c6d11 1error[E0373]: closure may outlive the current function, but it borrows `books`, which is owned by the current function
0731742a 2 --> $DIR/borrowck-escaping-closure-error-1.rs:13:11
ff7c6d11 3 |
0531ce1d 4LL | spawn(|| books.push(4));
ff7c6d11
XL
5 | ^^ ----- `books` is borrowed here
6 | |
7 | may outlive borrowed value `books`
48663c56
XL
8 |
9note: function requires argument type to outlive `'static`
10 --> $DIR/borrowck-escaping-closure-error-1.rs:13:5
11 |
12LL | spawn(|| books.push(4));
13 | ^^^^^^^^^^^^^^^^^^^^^^^
ff7c6d11
XL
14help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword
15 |
0531ce1d 16LL | spawn(move || books.push(4));
94222f64 17 | ++++
ff7c6d11
XL
18
19error: aborting due to previous error
20
0531ce1d 21For more information about this error, try `rustc --explain E0373`.