From 56b6b128b53efa309435ad6ece2d5c4621178851 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Thu, 8 Jul 2021 22:53:53 +0100 Subject: [PATCH] Minor fixes/compilation after revert --- src/lua.rs | 10 ++++++---- src/util.rs | 16 ++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/lua.rs b/src/lua.rs index bbd08a2..c64c07a 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -344,7 +344,8 @@ impl Lua { let extra = &mut *lua.extra; - if cfg!(any(feature = "lua54", feature = "lua53", feature = "lua52")) { + #[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))] + { extra.mem_info = mem_info; } @@ -408,8 +409,8 @@ impl Lua { // Create empty Waker slot push_gc_userdata::>(state, None)?; - let waker_key = &WAKER_REGISTRY_KEY as *const u8 as *const c_void; protect_lua(state, 1, 0, |state| { + let waker_key = &WAKER_REGISTRY_KEY as *const u8 as *const c_void; ffi::lua_rawsetp(state, ffi::LUA_REGISTRYINDEX, waker_key); })?; } @@ -450,9 +451,9 @@ impl Lua { })); ffi::lua_pushlightuserdata(main_state, extra as *mut c_void); - let extra_key = &EXTRA_REGISTRY_KEY as *const u8 as *const c_void; mlua_expect!( protect_lua(main_state, 1, 0, |state| { + let extra_key = &EXTRA_REGISTRY_KEY as *const u8 as *const c_void; ffi::lua_rawsetp(state, ffi::LUA_REGISTRYINDEX, extra_key) }), "Error while storing extra data", @@ -1888,7 +1889,8 @@ impl Lua { where 'lua: 'callback, { - if cfg!(any(feature = "lua54", feature = "lua53", feature = "lua52")) { + #[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52"))] + { let libs = unsafe { (*self.extra).libs }; if !libs.contains(StdLib::COROUTINE) { self.load_from_std_lib(StdLib::COROUTINE)?; diff --git a/src/util.rs b/src/util.rs index 8eab90f..cbcf294 100644 --- a/src/util.rs +++ b/src/util.rs @@ -232,7 +232,7 @@ where protect_lua(state, 2, 0, |state| { ffi::lua_pushlstring(state, field.as_ptr() as *const c_char, field.len()); ffi::lua_rotate(state, -3, 2); - ffi::lua_rawset(state, -3) + ffi::lua_rawset(state, -3); }) } @@ -409,7 +409,7 @@ pub unsafe fn init_userdata_metatable( } } protect_lua(state, 3, 1, |state| { - ffi::lua_pushcclosure(state, meta_index_impl, 3) + ffi::lua_pushcclosure(state, meta_index_impl, 3); })?; } _ => mlua_panic!("improper __index type {}", index_type), @@ -425,7 +425,7 @@ pub unsafe fn init_userdata_metatable( ffi::LUA_TNIL | ffi::LUA_TTABLE | ffi::LUA_TFUNCTION => { ffi::lua_pushvalue(state, field_setters); protect_lua(state, 2, 1, |state| { - ffi::lua_pushcclosure(state, meta_newindex_impl, 2) + ffi::lua_pushcclosure(state, meta_newindex_impl, 2); })?; } _ => mlua_panic!("improper __newindex type {}", newindex_type), @@ -681,7 +681,7 @@ pub unsafe fn init_gc_metatable_for( } protect_lua(state, 1, 0, |state| { - ffi::lua_rawsetp(state, ffi::LUA_REGISTRYINDEX, ref_addr as *mut c_void) + ffi::lua_rawsetp(state, ffi::LUA_REGISTRYINDEX, ref_addr as *mut c_void); })?; Ok(()) @@ -840,17 +840,17 @@ pub unsafe fn init_error_registry(state: *mut ffi::lua_State) -> Result<()> { } ffi::lua_pop(state, 1); - let destructed_metatable_key = &DESTRUCTED_USERDATA_METATABLE as *const u8 as *const c_void; protect_lua(state, 1, 0, |state| { - ffi::lua_rawsetp(state, ffi::LUA_REGISTRYINDEX, destructed_metatable_key) + let destructed_mt_key = &DESTRUCTED_USERDATA_METATABLE as *const u8 as *const c_void; + ffi::lua_rawsetp(state, ffi::LUA_REGISTRYINDEX, destructed_mt_key); })?; // Create error print buffer init_gc_metatable_for::(state, None)?; push_gc_userdata(state, String::new())?; - let err_buf_key = &ERROR_PRINT_BUFFER_KEY as *const u8 as *const c_void; protect_lua(state, 1, 0, |state| { - ffi::lua_rawsetp(state, ffi::LUA_REGISTRYINDEX, err_buf_key) + let err_buf_key = &ERROR_PRINT_BUFFER_KEY as *const u8 as *const c_void; + ffi::lua_rawsetp(state, ffi::LUA_REGISTRYINDEX, err_buf_key); })?; Ok(())