summaryrefslogtreecommitdiff
path: root/tests/compile_fail/function_borrow.stderr
blob: c1c4d1fd9c5c1f5e44ff244f88daec8791827db6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
error[E0373]: closure may outlive the current function, but it borrows `test`, which is owned by the current function
  --> $DIR/function_borrow.rs:9:33
   |
9  |     let _ = lua.create_function(|_, ()| -> Result<i32> {
   |                                 ^^^^^^^^^^^^^^^^^^^^^^ may outlive borrowed value `test`
10 |         Ok(test.0)
   |            ---- `test` is borrowed here
   |
note: function requires argument type to outlive `'static`
  --> $DIR/function_borrow.rs:9:13
   |
9  |       let _ = lua.create_function(|_, ()| -> Result<i32> {
   |  _____________^
10 | |         Ok(test.0)
11 | |     });
   | |______^
help: to force the closure to take ownership of `test` (and any other referenced variables), use the `move` keyword
   |
9  |     let _ = lua.create_function(move |_, ()| -> Result<i32> {
   |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^