summaryrefslogtreecommitdiff
path: root/tests/compile/scope_invariance.stderr
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2020-05-12 02:50:58 +0100
committerAlex Orlenko <zxteam@protonmail.com>2020-05-12 03:16:29 +0100
commit1492790eced20ccf6f8e838b72a7c035f21dec6b (patch)
treef0ca4d52e0ee49775a3c06b2d330ef3b4fa93d5f /tests/compile/scope_invariance.stderr
parente88f086ed8b8db6236adf974db28aa9f846d1de8 (diff)
downloadmlua-1492790eced20ccf6f8e838b72a7c035f21dec6b.zip
Update compile tests to include async/send features
Diffstat (limited to 'tests/compile/scope_invariance.stderr')
-rw-r--r--tests/compile/scope_invariance.stderr25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/compile/scope_invariance.stderr b/tests/compile/scope_invariance.stderr
new file mode 100644
index 0000000..ee2a525
--- /dev/null
+++ b/tests/compile/scope_invariance.stderr
@@ -0,0 +1,25 @@
+error[E0373]: closure may outlive the current function, but it borrows `test`, which is owned by the current function
+ --> $DIR/scope_invariance.rs:14:38
+ |
+9 | lua.scope(|scope| {
+ | ----- has type `&mlua::scope::Scope<'_, '1>`
+...
+14 | .create_function_mut(|_, ()| {
+ | ^^^^^^^ may outlive borrowed value `test`
+15 | test.field = 42;
+ | ---- `test` is borrowed here
+ |
+note: function requires argument type to outlive `'1`
+ --> $DIR/scope_invariance.rs:13:13
+ |
+13 | / scope
+14 | | .create_function_mut(|_, ()| {
+15 | | test.field = 42;
+16 | | //~^ error: `test` does not live long enough
+17 | | Ok(())
+18 | | })?
+ | |__________________^
+help: to force the closure to take ownership of `test` (and any other referenced variables), use the `move` keyword
+ |
+14 | .create_function_mut(move |_, ()| {
+ | ^^^^^^^^^^^^