From ae677b0918179c98ecd747d6fd74f3d3883fc0bc Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Mon, 4 Nov 2019 16:31:19 +0000 Subject: [PATCH] Move lua 5.1 support under new "lua51" feature --- Cargo.toml | 1 + build.rs | 12 +++++++--- src/ffi/lauxlib.rs | 10 ++++----- src/ffi/lua.rs | 52 +++++++++++++++++++++---------------------- src/ffi/mod.rs | 6 ++--- src/lua.rs | 10 ++++----- src/scope.rs | 4 ++-- src/userdata.rs | 4 ++-- src/util.rs | 6 ++--- tests/compile_fail.rs | 1 + tests/tests.rs | 10 ++++----- tests/thread.rs | 2 +- 12 files changed, 63 insertions(+), 55 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 336c062..b4ccb35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ members = [ [features] default = ["lua53"] lua53 = [] +lua51 = [] luajit = [] [dependencies] diff --git a/build.rs b/build.rs index 4f91483..8c095eb 100644 --- a/build.rs +++ b/build.rs @@ -107,8 +107,14 @@ fn main() { // Find lua via pkg-config - #[cfg(all(feature = "lua53", feature = "luajit"))] - panic!("Cannot enable lua53 and luajit simultaneously"); + #[cfg(not(any(feature = "lua53", feature = "lua51", feature = "luajit")))] + panic!("You must enable one of the features: lua53, lua51, luajit"); + + #[cfg(all(feature = "lua53", any(feature = "lua51", feature = "luajit")))] + panic!("You can enable only one of the features: lua53, lua51, luajit"); + + #[cfg(all(feature = "lua51", feature = "luajit"))] + panic!("You can enable only one of the features: lua53, lua51, luajit"); #[cfg(feature = "lua53")] { @@ -126,7 +132,7 @@ fn main() { }; } - #[cfg(all(not(feature = "lua53"), not(feature = "luajit")))] + #[cfg(feature = "lua51")] { let mut lua = pkg_config::Config::new() .range_version((Bound::Included("5.1"), Bound::Excluded("5.2"))) diff --git a/src/ffi/lauxlib.rs b/src/ffi/lauxlib.rs index 941755f..9eb0791 100644 --- a/src/ffi/lauxlib.rs +++ b/src/ffi/lauxlib.rs @@ -31,7 +31,7 @@ use super::lua::{self, lua_CFunction, lua_Integer, lua_Number, lua_State}; #[cfg(feature = "lua53")] pub use super::glue::LUAL_NUMSIZES; -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] pub use super::compat53::{ luaL_checkversion, luaL_getmetafield, luaL_getsubtable, luaL_len, luaL_loadbufferx, luaL_newmetatable, luaL_requiref, luaL_setfuncs, luaL_setmetatable, luaL_testudata, @@ -63,7 +63,7 @@ extern "C" { #[cfg(feature = "lua53")] pub fn luaL_getmetafield(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] #[link_name = "luaL_getmetafield"] pub fn luaL_getmetafield_51(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int; @@ -89,7 +89,7 @@ extern "C" { #[cfg(feature = "lua53")] pub fn luaL_newmetatable(L: *mut lua_State, tname: *const c_char) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] #[link_name = "luaL_newmetatable"] pub fn luaL_newmetatable_51(L: *mut lua_State, tname: *const c_char) -> c_int; @@ -127,7 +127,7 @@ extern "C" { #[cfg(feature = "lua53")] pub fn luaL_loadfilex(L: *mut lua_State, filename: *const c_char, mode: *const c_char) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn luaL_loadfile(L: *mut lua_State, filename: *const c_char) -> c_int; } @@ -146,7 +146,7 @@ extern "C" { name: *const c_char, mode: *const c_char, ) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn luaL_loadbuffer( L: *mut lua_State, buff: *const c_char, diff --git a/src/ffi/lua.rs b/src/ffi/lua.rs index ae14a6b..7286841 100644 --- a/src/ffi/lua.rs +++ b/src/ffi/lua.rs @@ -33,7 +33,7 @@ use super::luaconf; pub use super::glue::{LUA_RELEASE, LUA_VERSION, LUA_VERSION_NUM}; pub use super::glue::LUA_REGISTRYINDEX; -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] pub use super::glue::{LUA_ENVIRONINDEX, LUA_GLOBALSINDEX}; pub const LUA_SIGNATURE: &'static [u8] = b"\x1bLua"; @@ -41,7 +41,7 @@ pub const LUA_SIGNATURE: &'static [u8] = b"\x1bLua"; // option for multiple returns in 'lua_pcall' and 'lua_call' pub const LUA_MULTRET: c_int = -1; -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] pub use super::compat53::{ lua_absindex, lua_compare, lua_copy, lua_getextraspace, lua_getfield, lua_geti, lua_gettable, lua_getuservalue, lua_isinteger, lua_len, lua_pushglobaltable, lua_pushlstring, lua_pushstring, @@ -63,7 +63,7 @@ pub const LUA_ERRSYNTAX: c_int = 3; pub const LUA_ERRMEM: c_int = 4; #[cfg(feature = "lua53")] pub const LUA_ERRGCMM: c_int = 5; -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] pub const LUA_ERRERR: c_int = 5; #[cfg(feature = "lua53")] pub const LUA_ERRERR: c_int = 6; @@ -150,11 +150,11 @@ extern "C" { pub fn lua_gettop(L: *mut lua_State) -> c_int; pub fn lua_settop(L: *mut lua_State, idx: c_int); pub fn lua_pushvalue(L: *mut lua_State, idx: c_int); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_remove(L: *mut lua_State, idx: c_int); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_insert(L: *mut lua_State, idx: c_int); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_replace(L: *mut lua_State, idx: c_int); #[cfg(feature = "lua53")] pub fn lua_rotate(L: *mut lua_State, idx: c_int, n: c_int); @@ -174,17 +174,17 @@ extern "C" { pub fn lua_type(L: *mut lua_State, idx: c_int) -> c_int; pub fn lua_typename(L: *mut lua_State, tp: c_int) -> *const c_char; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_tonumber(L: *mut lua_State, idx: c_int) -> lua_Number; #[cfg(feature = "lua53")] pub fn lua_tonumberx(L: *mut lua_State, idx: c_int, isnum: *mut c_int) -> lua_Number; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_tointeger(L: *mut lua_State, idx: c_int) -> lua_Integer; #[cfg(feature = "lua53")] pub fn lua_tointegerx(L: *mut lua_State, idx: c_int, isnum: *mut c_int) -> lua_Integer; pub fn lua_toboolean(L: *mut lua_State, idx: c_int) -> c_int; pub fn lua_tolstring(L: *mut lua_State, idx: c_int, len: *mut usize) -> *const c_char; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_objlen(L: *mut lua_State, idx: c_int) -> usize; #[cfg(feature = "lua53")] pub fn lua_rawlen(L: *mut lua_State, idx: c_int) -> usize; @@ -234,10 +234,10 @@ pub const LUA_OPLT: c_int = 1; pub const LUA_OPLE: c_int = 2; extern "C" { - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_equal(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int; pub fn lua_rawequal(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_lessthan(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int; #[cfg(feature = "lua53")] pub fn lua_compare(L: *mut lua_State, idx1: c_int, idx2: c_int, op: c_int) -> c_int; @@ -251,13 +251,13 @@ extern "C" { #[cfg(feature = "lua53")] pub fn lua_pushlstring(L: *mut lua_State, s: *const c_char, l: usize) -> *const c_char; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] #[link_name = "lua_pushlstring"] pub fn lua_pushlstring_51(L: *mut lua_State, s: *const c_char, l: usize) -> *const c_char; #[cfg(feature = "lua53")] pub fn lua_pushstring(L: *mut lua_State, s: *const c_char) -> *const c_char; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] #[link_name = "lua_pushstring"] pub fn lua_pushstring_51(L: *mut lua_State, s: *const c_char) -> *const c_char; @@ -277,13 +277,13 @@ extern "C" { #[cfg(feature = "lua53")] pub fn lua_gettable(L: *mut lua_State, idx: c_int) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] #[link_name = "lua_gettable"] pub fn lua_gettable_51(L: *mut lua_State, idx: c_int) -> c_int; #[cfg(feature = "lua53")] pub fn lua_getfield(L: *mut lua_State, idx: c_int, k: *const c_char) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] #[link_name = "lua_getfield"] pub fn lua_getfield_51(L: *mut lua_State, idx: c_int, k: *const c_char) -> c_int; @@ -292,13 +292,13 @@ extern "C" { #[cfg(feature = "lua53")] pub fn lua_rawget(L: *mut lua_State, idx: c_int) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] #[link_name = "lua_rawget"] pub fn lua_rawget_51(L: *mut lua_State, idx: c_int); #[cfg(feature = "lua53")] pub fn lua_rawgeti(L: *mut lua_State, idx: c_int, n: lua_Integer) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] #[link_name = "lua_rawgeti"] pub fn lua_rawgeti_51(L: *mut lua_State, idx: c_int, n: lua_Integer); @@ -310,7 +310,7 @@ extern "C" { pub fn lua_getmetatable(L: *mut lua_State, objindex: c_int) -> c_int; #[cfg(feature = "lua53")] pub fn lua_getuservalue(L: *mut lua_State, idx: c_int) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_getfenv(L: *mut lua_State, idx: c_int); } @@ -329,7 +329,7 @@ extern "C" { pub fn lua_setmetatable(L: *mut lua_State, objindex: c_int) -> c_int; #[cfg(feature = "lua53")] pub fn lua_setuservalue(L: *mut lua_State, idx: c_int); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_setfenv(L: *mut lua_State, idx: c_int) -> c_int; } @@ -352,9 +352,9 @@ extern "C" { ctx: lua_KContext, k: Option, ) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_call(L: *mut lua_State, nargs: c_int, nresults: c_int); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_pcall(L: *mut lua_State, nargs: c_int, nresults: c_int, errfunc: c_int) -> c_int; pub fn lua_load( L: *mut lua_State, @@ -393,12 +393,12 @@ extern "C" { ctx: lua_KContext, k: Option, ) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] pub fn lua_yield(L: *mut lua_State, nresults: c_int) -> c_int; #[cfg(feature = "lua53")] pub fn lua_resume(L: *mut lua_State, from: *mut lua_State, narg: c_int) -> c_int; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] #[link_name = "lua_resume"] pub fn lua_resume_51(L: *mut lua_State, narg: c_int) -> c_int; @@ -530,13 +530,13 @@ pub unsafe fn lua_pushliteral(L: *mut lua_State, s: &'static str) -> *const c_ch lua_pushlstring(L, c_str.as_ptr(), c_str.as_bytes().len()) } -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] #[inline(always)] pub unsafe fn lua_setglobal(L: *mut lua_State, var: *const c_char) { lua_setfield(L, LUA_GLOBALSINDEX, var) } -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] #[inline(always)] pub unsafe fn lua_getglobal(L: *mut lua_State, var: *const c_char) -> c_int { lua_getfield(L, LUA_GLOBALSINDEX, var) @@ -629,7 +629,7 @@ pub struct lua_Debug { i_ci: *mut c_void, } -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] #[repr(C)] pub struct lua_Debug { pub event: c_int, diff --git a/src/ffi/mod.rs b/src/ffi/mod.rs index 14ac3c0..8a4ecaa 100644 --- a/src/ffi/mod.rs +++ b/src/ffi/mod.rs @@ -39,7 +39,7 @@ pub use self::lua::{ #[cfg(feature = "lua53")] pub use self::lua::{lua_KContext, lua_KFunction, lua_Unsigned}; -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] pub use self::lua::lua_setfenv; // C API functions @@ -203,7 +203,7 @@ pub use self::lua::{ LUA_OPUNM, LUA_RIDX_GLOBALS, LUA_RIDX_MAINTHREAD, }; -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] pub use self::lua::{LUA_ENVIRONINDEX, LUA_GLOBALSINDEX}; // constants from lauxlib.h @@ -226,7 +226,7 @@ mod glue { include!(concat!(env!("OUT_DIR"), "/glue.rs")); } -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] mod compat53; mod lauxlib; diff --git a/src/lua.rs b/src/lua.rs index 71e131d..9b8d7d4 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -16,7 +16,7 @@ use crate::table::Table; use crate::thread::Thread; use crate::types::{Callback, Integer, LightUserData, LuaRef, Number, RegistryKey}; use crate::userdata::{AnyUserData, MetaMethod, UserData, UserDataMethods}; -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] use crate::util::set_main_state; use crate::util::{ assert_stack, callback_error, check_stack, get_main_state, get_userdata, get_wrapped_error, @@ -84,7 +84,7 @@ impl Lua { ffi::luaL_requiref(state, cstr!("package"), ffi::luaopen_package, 1); #[cfg(feature = "lua53")] ffi::lua_pop(state, 9); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] ffi::lua_pop(state, 7); let mut lua = Lua::init_from_ptr(state); @@ -97,7 +97,7 @@ impl Lua { pub unsafe fn init_from_ptr(state: *mut ffi::lua_State) -> Lua { #[cfg(feature = "lua53")] let main_state = get_main_state(state); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] let main_state = { set_main_state(state); state @@ -316,7 +316,7 @@ impl Lua { self.push_value(env)?; #[cfg(feature = "lua53")] ffi::lua_setupvalue(self.state, -2, 1); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] ffi::lua_setfenv(self.state, -2); } Ok(Function(self.pop_ref())) @@ -507,7 +507,7 @@ impl Lua { assert_stack(self.state, 2); #[cfg(feature = "lua53")] ffi::lua_rawgeti(self.state, ffi::LUA_REGISTRYINDEX, ffi::LUA_RIDX_GLOBALS); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] ffi::lua_pushvalue(self.state, ffi::LUA_GLOBALSINDEX); Table(self.pop_ref()) } diff --git a/src/scope.rs b/src/scope.rs index 2c88083..aecf38c 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -175,7 +175,7 @@ impl<'lua, 'scope> Scope<'lua, 'scope> { assert_stack(lua.state, 1); lua.push_ref(&u.0); ffi::lua_getuservalue(lua.state, -1); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] { ffi::lua_pushinteger(lua.state, 1); ffi::lua_gettable(lua.state, -2); @@ -247,7 +247,7 @@ impl<'lua, 'scope> Scope<'lua, 'scope> { push_userdata(lua.state, ())?; #[cfg(feature = "lua53")] ffi::lua_pushlightuserdata(lua.state, data.as_ptr() as *mut c_void); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] protect_lua_closure(lua.state, 0, 1, |state| { // Lua 5.1 allows to store only table. Then we will wrap the value. ffi::lua_createtable(state, 1, 0); diff --git a/src/userdata.rs b/src/userdata.rs index bc6b62e..15c200e 100644 --- a/src/userdata.rs +++ b/src/userdata.rs @@ -333,7 +333,7 @@ impl<'lua> AnyUserData<'lua> { /// [`get_user_value`]: #method.get_user_value pub fn set_user_value>(&self, v: V) -> Result<()> { let lua = self.0.lua; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] let v = { // Lua 5.1 allows to store only table. Then we will wrap the value. let t = lua.create_table()?; @@ -364,7 +364,7 @@ impl<'lua> AnyUserData<'lua> { ffi::lua_getuservalue(lua.state, -1); lua.pop_value() }; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] return crate::Table::from_lua(res, lua)?.get(1); #[cfg(feature = "lua53")] V::from_lua(res, lua) diff --git a/src/util.rs b/src/util.rs index 4e0b64f..d8b9c50 100644 --- a/src/util.rs +++ b/src/util.rs @@ -444,7 +444,7 @@ pub unsafe extern "C" fn error_traceback(state: *mut ffi::lua_State) -> c_int { } // Does not call lua_checkstack, uses 2 stack spaces. -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] pub unsafe fn set_main_state(state: *mut ffi::lua_State) { ffi::lua_pushlightuserdata(state, &MAIN_THREAD_REGISTRY_KEY as *const u8 as *mut c_void); ffi::lua_pushthread(state); @@ -455,7 +455,7 @@ pub unsafe fn set_main_state(state: *mut ffi::lua_State) { pub unsafe fn get_main_state(state: *mut ffi::lua_State) -> *mut ffi::lua_State { #[cfg(feature = "lua53")] ffi::lua_rawgeti(state, ffi::LUA_REGISTRYINDEX, ffi::LUA_RIDX_MAINTHREAD); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] { ffi::lua_pushlightuserdata(state, &MAIN_THREAD_REGISTRY_KEY as *const u8 as *mut c_void); ffi::lua_rawget(state, ffi::LUA_REGISTRYINDEX); @@ -751,7 +751,7 @@ unsafe fn get_destructed_userdata_metatable(state: *mut ffi::lua_State) { ffi::lua_rawget(state, ffi::LUA_REGISTRYINDEX); } -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] static MAIN_THREAD_REGISTRY_KEY: u8 = 0; static ERROR_METATABLE_REGISTRY_KEY: u8 = 0; static PANIC_METATABLE_REGISTRY_KEY: u8 = 0; diff --git a/tests/compile_fail.rs b/tests/compile_fail.rs index 20b0587..3c44654 100644 --- a/tests/compile_fail.rs +++ b/tests/compile_fail.rs @@ -1,3 +1,4 @@ +#[cfg(any(feature = "lua53", feature = "lua51"))] #[test] fn test_compile_fail() { let t = trybuild::TestCases::new(); diff --git a/tests/tests.rs b/tests/tests.rs index d4c4cb6..6477204 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -402,7 +402,7 @@ fn test_num_conversion() -> Result<()> { assert_eq!(lua.load("1.0").eval::()?, 1.0); #[cfg(feature = "lua53")] assert_eq!(lua.load("1.0").eval::()?, "1.0"); - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] assert_eq!(lua.load("1.0").eval::()?, "1"); assert_eq!(lua.load("1.5").eval::()?, 1); @@ -435,7 +435,7 @@ fn test_pcall_xpcall() -> Result<()> { assert!(lua.load("xpcall(function() end)").exec().is_err()); // Lua 5.3 / LuaJIT compatible version of xpcall - #[cfg(all(not(feature = "lua53"), not(feature = "luajit")))] + #[cfg(feature = "lua51")] lua.load( r#" local xpcall_orig = xpcall @@ -482,7 +482,7 @@ fn test_pcall_xpcall() -> Result<()> { globals.get::<_, std::string::String>("xpcall_error")?, "testerror" ); - #[cfg(all(not(feature = "lua53"), not(feature = "luajit")))] + #[cfg(feature = "lua51")] assert!(globals .get::<_, String>("xpcall_error")? .to_str()? @@ -813,14 +813,14 @@ fn context_thread() -> Result<()> { #[cfg(feature = "lua53")] f.call::<_, ()>(lua.current_thread())?; - #[cfg(not(feature = "lua53"))] + #[cfg(any(feature = "lua51", feature = "luajit"))] f.call::<_, ()>(Nil)?; Ok(()) } #[test] -#[cfg(not(feature = "lua53"))] +#[cfg(any(feature = "lua51", feature = "luajit"))] fn context_thread_51() -> Result<()> { let lua = Lua::new(); diff --git a/tests/thread.rs b/tests/thread.rs index cd09002..24f3b10 100644 --- a/tests/thread.rs +++ b/tests/thread.rs @@ -113,7 +113,7 @@ fn coroutine_from_closure() -> Result<()> { #[cfg(any(feature = "lua53", feature = "luajit"))] let thrd: Thread = lua.load("coroutine.create(main)").eval()?; - #[cfg(all(not(feature = "lua53"), not(feature = "luajit")))] + #[cfg(feature = "lua51")] let thrd: Thread = lua .load("coroutine.create(function(...) return main(unpack(arg)) end)") .eval()?;