summaryrefslogtreecommitdiff
path: root/tests
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
parente88f086ed8b8db6236adf974db28aa9f846d1de8 (diff)
downloadmlua-1492790eced20ccf6f8e838b72a7c035f21dec6b.zip
Update compile tests to include async/send features
Diffstat (limited to 'tests')
-rw-r--r--tests/compile.rs24
-rw-r--r--tests/compile/async_nonstatic_userdata.rs (renamed from tests/compile_fail/async_nonstatic_userdata.rs)0
-rw-r--r--tests/compile/async_nonstatic_userdata.stderr (renamed from tests/compile_fail/async_nonstatic_userdata.stderr)10
-rw-r--r--tests/compile/function_borrow.rs (renamed from tests/compile_fail/function_borrow.rs)0
-rw-r--r--tests/compile/function_borrow.stderr (renamed from tests/compile_fail/function_borrow.stderr)0
-rw-r--r--tests/compile/lua_norefunwindsafe.rs (renamed from tests/compile_fail/lua_norefunwindsafe.rs)0
-rw-r--r--tests/compile/lua_norefunwindsafe.stderr (renamed from tests/compile_fail/lua_norefunwindsafe.stderr)2
-rw-r--r--tests/compile/non_send.rs17
-rw-r--r--tests/compile/non_send.stderr14
-rw-r--r--tests/compile/ref_nounwindsafe.rs (renamed from tests/compile_fail/ref_nounwindsafe.rs)0
-rw-r--r--tests/compile/ref_nounwindsafe.stderr (renamed from tests/compile_fail/ref_nounwindsafe.stderr)2
-rw-r--r--tests/compile/scope_callback_capture.rs (renamed from tests/compile_fail/scope_callback_capture.rs)0
-rw-r--r--tests/compile/scope_callback_capture.stderr (renamed from tests/compile_fail/scope_callback_capture.stderr)0
-rw-r--r--tests/compile/scope_callback_inner.rs (renamed from tests/compile_fail/scope_callback_inner.rs)0
-rw-r--r--tests/compile/scope_callback_inner.stderr (renamed from tests/compile_fail/scope_callback_inner.stderr)0
-rw-r--r--tests/compile/scope_callback_outer.rs (renamed from tests/compile_fail/scope_callback_outer.rs)0
-rw-r--r--tests/compile/scope_callback_outer.stderr (renamed from tests/compile_fail/scope_callback_outer.stderr)0
-rw-r--r--tests/compile/scope_invariance.rs (renamed from tests/compile_fail/scope_invariance.rs)0
-rw-r--r--tests/compile/scope_invariance.stderr (renamed from tests/compile_fail/scope_invariance.stderr)0
-rw-r--r--tests/compile/scope_mutable_aliasing.rs (renamed from tests/compile_fail/scope_mutable_aliasing.rs)0
-rw-r--r--tests/compile/scope_mutable_aliasing.stderr (renamed from tests/compile_fail/scope_mutable_aliasing.stderr)0
-rw-r--r--tests/compile/scope_userdata_borrow.rs (renamed from tests/compile_fail/scope_userdata_borrow.rs)0
-rw-r--r--tests/compile/scope_userdata_borrow.stderr (renamed from tests/compile_fail/scope_userdata_borrow.stderr)0
-rw-r--r--tests/compile/static_callback_args.rs (renamed from tests/compile_fail/static_callback_args.rs)0
-rw-r--r--tests/compile/static_callback_args.stderr (renamed from tests/compile_fail/static_callback_args.stderr)0
-rw-r--r--tests/compile/userdata_borrow.rs (renamed from tests/compile_fail/userdata_borrow.rs)0
-rw-r--r--tests/compile/userdata_borrow.stderr (renamed from tests/compile_fail/userdata_borrow.stderr)0
-rw-r--r--tests/compile_fail.rs6
28 files changed, 62 insertions, 13 deletions
diff --git a/tests/compile.rs b/tests/compile.rs
new file mode 100644
index 0000000..e4d822a
--- /dev/null
+++ b/tests/compile.rs
@@ -0,0 +1,24 @@
+#[test]
+#[ignore]
+fn test_compilation() {
+ let t = trybuild::TestCases::new();
+
+ t.compile_fail("tests/compile/function_borrow.rs");
+ t.compile_fail("tests/compile/lua_norefunwindsafe.rs");
+ t.compile_fail("tests/compile/ref_nounwindsafe.rs");
+ t.compile_fail("tests/compile/scope_callback_capture.rs");
+ t.compile_fail("tests/compile/scope_callback_inner.rs");
+ t.compile_fail("tests/compile/scope_callback_outer.rs");
+ t.compile_fail("tests/compile/scope_invariance.rs");
+ t.compile_fail("tests/compile/scope_mutable_aliasing.rs");
+ t.compile_fail("tests/compile/scope_userdata_borrow.rs");
+ t.compile_fail("tests/compile/static_callback_args.rs");
+
+ #[cfg(feature = "async")]
+ t.compile_fail("tests/compile/async_nonstatic_userdata.rs");
+
+ #[cfg(feature = "send")]
+ t.compile_fail("tests/compile/non_send.rs");
+ #[cfg(not(feature = "send"))]
+ t.pass("tests/compile/non_send.rs");
+}
diff --git a/tests/compile_fail/async_nonstatic_userdata.rs b/tests/compile/async_nonstatic_userdata.rs
index 8aede32..8aede32 100644
--- a/tests/compile_fail/async_nonstatic_userdata.rs
+++ b/tests/compile/async_nonstatic_userdata.rs
diff --git a/tests/compile_fail/async_nonstatic_userdata.stderr b/tests/compile/async_nonstatic_userdata.stderr
index 25e9e5d..a604cd4 100644
--- a/tests/compile_fail/async_nonstatic_userdata.stderr
+++ b/tests/compile/async_nonstatic_userdata.stderr
@@ -1,5 +1,5 @@
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
- --> $DIR/scope_async_userdata.rs:11:72
+ --> $DIR/async_nonstatic_userdata.rs:11:72
|
11 | methods.add_async_method("print", |_, data, ()| async move {
| ________________________________________________________________________^
@@ -9,12 +9,12 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requiremen
| |_____________^
|
note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 9:10...
- --> $DIR/scope_async_userdata.rs:9:10
+ --> $DIR/async_nonstatic_userdata.rs:9:10
|
9 | impl<'a> UserData for MyUserData<'a> {
| ^^
note: ...so that the types are compatible
- --> $DIR/scope_async_userdata.rs:11:72
+ --> $DIR/async_nonstatic_userdata.rs:11:72
|
11 | methods.add_async_method("print", |_, data, ()| async move {
| ________________________________________________________________________^
@@ -25,12 +25,12 @@ note: ...so that the types are compatible
= note: expected `main::MyUserData<'_>`
found `main::MyUserData<'a>`
note: but, the lifetime must be valid for the lifetime `'lua` as defined on the method body at 10:24...
- --> $DIR/scope_async_userdata.rs:10:24
+ --> $DIR/async_nonstatic_userdata.rs:10:24
|
10 | fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
| ^^^^
note: ...so that the type `impl std::future::Future` will meet its required lifetime bounds
- --> $DIR/scope_async_userdata.rs:11:21
+ --> $DIR/async_nonstatic_userdata.rs:11:21
|
11 | methods.add_async_method("print", |_, data, ()| async move {
| ^^^^^^^^^^^^^^^^
diff --git a/tests/compile_fail/function_borrow.rs b/tests/compile/function_borrow.rs
index f64f3b8..f64f3b8 100644
--- a/tests/compile_fail/function_borrow.rs
+++ b/tests/compile/function_borrow.rs
diff --git a/tests/compile_fail/function_borrow.stderr b/tests/compile/function_borrow.stderr
index c1c4d1f..c1c4d1f 100644
--- a/tests/compile_fail/function_borrow.stderr
+++ b/tests/compile/function_borrow.stderr
diff --git a/tests/compile_fail/lua_norefunwindsafe.rs b/tests/compile/lua_norefunwindsafe.rs
index 805f61f..805f61f 100644
--- a/tests/compile_fail/lua_norefunwindsafe.rs
+++ b/tests/compile/lua_norefunwindsafe.rs
diff --git a/tests/compile_fail/lua_norefunwindsafe.stderr b/tests/compile/lua_norefunwindsafe.stderr
index 7d03bed..6dff810 100644
--- a/tests/compile_fail/lua_norefunwindsafe.stderr
+++ b/tests/compile/lua_norefunwindsafe.stderr
@@ -8,4 +8,4 @@ error[E0277]: the type `std::cell::UnsafeCell<()>` may contain interior mutabili
= note: required because it appears within the type `std::marker::PhantomData<std::cell::UnsafeCell<()>>`
= note: required because it appears within the type `mlua::lua::Lua`
= note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&mlua::lua::Lua`
- = note: required because it appears within the type `[closure@$DIR/tests/compile_fail/lua_norefunwindsafe.rs:7:18: 7:48 lua:&mlua::lua::Lua]`
+ = note: required because it appears within the type `[closure@$DIR/tests/compile/lua_norefunwindsafe.rs:7:18: 7:48 lua:&mlua::lua::Lua]`
diff --git a/tests/compile/non_send.rs b/tests/compile/non_send.rs
new file mode 100644
index 0000000..fe030a5
--- /dev/null
+++ b/tests/compile/non_send.rs
@@ -0,0 +1,17 @@
+use std::cell::Cell;
+use std::rc::Rc;
+
+use mlua::{Lua, Result};
+
+fn main() -> Result<()> {
+ let lua = Lua::new();
+
+ let data = Rc::new(Cell::new(0));
+
+ lua.create_function(move |_, ()| {
+ Ok(data.get())
+ })?
+ .call::<_, i32>(())?;
+
+ Ok(())
+}
diff --git a/tests/compile/non_send.stderr b/tests/compile/non_send.stderr
new file mode 100644
index 0000000..e830d33
--- /dev/null
+++ b/tests/compile/non_send.stderr
@@ -0,0 +1,14 @@
+error[E0277]: `std::rc::Rc<std::cell::Cell<i32>>` cannot be sent between threads safely
+ --> $DIR/non_send.rs:11:9
+ |
+11 | lua.create_function(move |_, ()| {
+ | _________^^^^^^^^^^^^^^^_-
+ | | |
+ | | `std::rc::Rc<std::cell::Cell<i32>>` cannot be sent between threads safely
+12 | | Ok(data.get())
+13 | | })?
+ | |_____- within this `[closure@$DIR/tests/compile/non_send.rs:11:25: 13:6 data:std::rc::Rc<std::cell::Cell<i32>>]`
+ |
+ = help: within `[closure@$DIR/tests/compile/non_send.rs:11:25: 13:6 data:std::rc::Rc<std::cell::Cell<i32>>]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<std::cell::Cell<i32>>`
+ = note: required because it appears within the type `[closure@$DIR/tests/compile/non_send.rs:11:25: 13:6 data:std::rc::Rc<std::cell::Cell<i32>>]`
+ = note: required because of the requirements on the impl of `mlua::types::MaybeSend` for `[closure@$DIR/tests/compile/non_send.rs:11:25: 13:6 data:std::rc::Rc<std::cell::Cell<i32>>]`
diff --git a/tests/compile_fail/ref_nounwindsafe.rs b/tests/compile/ref_nounwindsafe.rs
index 8518c40..8518c40 100644
--- a/tests/compile_fail/ref_nounwindsafe.rs
+++ b/tests/compile/ref_nounwindsafe.rs
diff --git a/tests/compile_fail/ref_nounwindsafe.stderr b/tests/compile/ref_nounwindsafe.stderr
index 2d78b81..0b1b649 100644
--- a/tests/compile_fail/ref_nounwindsafe.stderr
+++ b/tests/compile/ref_nounwindsafe.stderr
@@ -10,4 +10,4 @@ error[E0277]: the type `std::cell::UnsafeCell<()>` may contain interior mutabili
= note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&mlua::lua::Lua`
= note: required because it appears within the type `mlua::types::LuaRef<'_>`
= note: required because it appears within the type `mlua::table::Table<'_>`
- = note: required because it appears within the type `[closure@$DIR/tests/compile_fail/ref_nounwindsafe.rs:8:18: 8:54 table:mlua::table::Table<'_>]`
+ = note: required because it appears within the type `[closure@$DIR/tests/compile/ref_nounwindsafe.rs:8:18: 8:54 table:mlua::table::Table<'_>]`
diff --git a/tests/compile_fail/scope_callback_capture.rs b/tests/compile/scope_callback_capture.rs
index 927c36d..927c36d 100644
--- a/tests/compile_fail/scope_callback_capture.rs
+++ b/tests/compile/scope_callback_capture.rs
diff --git a/tests/compile_fail/scope_callback_capture.stderr b/tests/compile/scope_callback_capture.stderr
index 8e9dec5..8e9dec5 100644
--- a/tests/compile_fail/scope_callback_capture.stderr
+++ b/tests/compile/scope_callback_capture.stderr
diff --git a/tests/compile_fail/scope_callback_inner.rs b/tests/compile/scope_callback_inner.rs
index 037c6ac..037c6ac 100644
--- a/tests/compile_fail/scope_callback_inner.rs
+++ b/tests/compile/scope_callback_inner.rs
diff --git a/tests/compile_fail/scope_callback_inner.stderr b/tests/compile/scope_callback_inner.stderr
index 1c5f3b5..1c5f3b5 100644
--- a/tests/compile_fail/scope_callback_inner.stderr
+++ b/tests/compile/scope_callback_inner.stderr
diff --git a/tests/compile_fail/scope_callback_outer.rs b/tests/compile/scope_callback_outer.rs
index 7c9974e..7c9974e 100644
--- a/tests/compile_fail/scope_callback_outer.rs
+++ b/tests/compile/scope_callback_outer.rs
diff --git a/tests/compile_fail/scope_callback_outer.stderr b/tests/compile/scope_callback_outer.stderr
index e1f98ce..e1f98ce 100644
--- a/tests/compile_fail/scope_callback_outer.stderr
+++ b/tests/compile/scope_callback_outer.stderr
diff --git a/tests/compile_fail/scope_invariance.rs b/tests/compile/scope_invariance.rs
index e4f4ea7..e4f4ea7 100644
--- a/tests/compile_fail/scope_invariance.rs
+++ b/tests/compile/scope_invariance.rs
diff --git a/tests/compile_fail/scope_invariance.stderr b/tests/compile/scope_invariance.stderr
index ee2a525..ee2a525 100644
--- a/tests/compile_fail/scope_invariance.stderr
+++ b/tests/compile/scope_invariance.stderr
diff --git a/tests/compile_fail/scope_mutable_aliasing.rs b/tests/compile/scope_mutable_aliasing.rs
index 6bdf498..6bdf498 100644
--- a/tests/compile_fail/scope_mutable_aliasing.rs
+++ b/tests/compile/scope_mutable_aliasing.rs
diff --git a/tests/compile_fail/scope_mutable_aliasing.stderr b/tests/compile/scope_mutable_aliasing.stderr
index c661826..c661826 100644
--- a/tests/compile_fail/scope_mutable_aliasing.stderr
+++ b/tests/compile/scope_mutable_aliasing.stderr
diff --git a/tests/compile_fail/scope_userdata_borrow.rs b/tests/compile/scope_userdata_borrow.rs
index 6546633..6546633 100644
--- a/tests/compile_fail/scope_userdata_borrow.rs
+++ b/tests/compile/scope_userdata_borrow.rs
diff --git a/tests/compile_fail/scope_userdata_borrow.stderr b/tests/compile/scope_userdata_borrow.stderr
index 1e422f4..1e422f4 100644
--- a/tests/compile_fail/scope_userdata_borrow.stderr
+++ b/tests/compile/scope_userdata_borrow.stderr
diff --git a/tests/compile_fail/static_callback_args.rs b/tests/compile/static_callback_args.rs
index 66dbf8b..66dbf8b 100644
--- a/tests/compile_fail/static_callback_args.rs
+++ b/tests/compile/static_callback_args.rs
diff --git a/tests/compile_fail/static_callback_args.stderr b/tests/compile/static_callback_args.stderr
index 561bcbe..561bcbe 100644
--- a/tests/compile_fail/static_callback_args.stderr
+++ b/tests/compile/static_callback_args.stderr
diff --git a/tests/compile_fail/userdata_borrow.rs b/tests/compile/userdata_borrow.rs
index 26eb3c7..26eb3c7 100644
--- a/tests/compile_fail/userdata_borrow.rs
+++ b/tests/compile/userdata_borrow.rs
diff --git a/tests/compile_fail/userdata_borrow.stderr b/tests/compile/userdata_borrow.stderr
index 7ac9670..7ac9670 100644
--- a/tests/compile_fail/userdata_borrow.stderr
+++ b/tests/compile/userdata_borrow.stderr
diff --git a/tests/compile_fail.rs b/tests/compile_fail.rs
deleted file mode 100644
index 5c20a2a..0000000
--- a/tests/compile_fail.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-#[test]
-#[ignore]
-fn test_compile_fail() {
- let t = trybuild::TestCases::new();
- t.compile_fail("tests/compile_fail/*.rs");
-}