Update compile tests to include async/send features
This commit is contained in:
parent
e88f086ed8
commit
1492790ece
|
@ -67,7 +67,8 @@ jobs:
|
|||
- name: Run compile tests
|
||||
if: ${{ matrix.os == 'ubuntu-18.04' && matrix.lua == 'lua53' }}
|
||||
run: |
|
||||
cargo test --release --no-default-features --features "lua53 vendored async send" -- --ignored
|
||||
cargo test --release --no-default-features --features "${{ matrix.lua }} vendored" -- --ignored
|
||||
cargo test --release --no-default-features --features "${{ matrix.lua }} vendored async send" -- --ignored
|
||||
shell: bash
|
||||
|
||||
rustfmt:
|
||||
|
|
|
@ -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");
|
||||
}
|
|
@ -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 {
|
||||
| ^^^^^^^^^^^^^^^^
|
|
@ -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]`
|
|
@ -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(())
|
||||
}
|
|
@ -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>>]`
|
|
@ -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<'_>]`
|
|
@ -1,6 +0,0 @@
|
|||
#[test]
|
||||
#[ignore]
|
||||
fn test_compile_fail() {
|
||||
let t = trybuild::TestCases::new();
|
||||
t.compile_fail("tests/compile_fail/*.rs");
|
||||
}
|
Loading…
Reference in New Issue