summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/compile-fail/scope_callback_capture.rs25
-rw-r--r--tests/compile-fail/scope_callback_escape.rs2
-rw-r--r--tests/compile-fail/scope_callback_inner.rs2
3 files changed, 27 insertions, 2 deletions
diff --git a/tests/compile-fail/scope_callback_capture.rs b/tests/compile-fail/scope_callback_capture.rs
new file mode 100644
index 0000000..4dbc881
--- /dev/null
+++ b/tests/compile-fail/scope_callback_capture.rs
@@ -0,0 +1,25 @@
+extern crate rlua;
+
+use rlua::*;
+
+fn main() {
+ struct Test {
+ field: i32,
+ }
+
+ let lua = Lua::new();
+ lua.scope(|scope| {
+ let mut inner: Option<Table> = None;
+ let f = scope
+ .create_function_mut(move |lua, t: Table| {
+ //~^ error: cannot infer an appropriate lifetime for autoref due to conflicting requirements
+ if let Some(old) = inner.take() {
+ // Access old callback `Lua`.
+ }
+ inner = Some(t);
+ Ok(())
+ })
+ .unwrap();
+ f.call::<_, ()>(lua.create_table()).unwrap();
+ });
+}
diff --git a/tests/compile-fail/scope_callback_escape.rs b/tests/compile-fail/scope_callback_escape.rs
index 2da9d61..43c5226 100644
--- a/tests/compile-fail/scope_callback_escape.rs
+++ b/tests/compile-fail/scope_callback_escape.rs
@@ -12,8 +12,8 @@ fn main() {
lua.scope(|scope| {
let f = scope
.create_function_mut(|_, t: Table| {
+ //~^^ error: borrowed data cannot be stored outside of its closure
outer = Some(t);
- //~^ error: `*outer` does not live long enough
Ok(())
})
.unwrap();
diff --git a/tests/compile-fail/scope_callback_inner.rs b/tests/compile-fail/scope_callback_inner.rs
index 6e95a9e..6d086c6 100644
--- a/tests/compile-fail/scope_callback_inner.rs
+++ b/tests/compile-fail/scope_callback_inner.rs
@@ -12,8 +12,8 @@ fn main() {
let mut inner: Option<Table> = None;
let f = scope
.create_function_mut(|_, t: Table| {
+ //~^ error: cannot infer an appropriate lifetime for autoref due to conflicting requirements
inner = Some(t);
- //~^ error: `inner` does not live long enough
Ok(())
})
.unwrap();