Fix compilation warnings on nightly rust
This commit is contained in:
parent
d201beadc9
commit
de2c5cd9a9
17
src/lua.rs
17
src/lua.rs
|
@ -100,13 +100,15 @@ impl Drop for Lua {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
if !self.ephemeral {
|
if !self.ephemeral {
|
||||||
let mut extra = mlua_expect!(self.extra.lock(), "extra is poisoned");
|
let extra = mlua_expect!(self.extra.lock(), "extra is poisoned");
|
||||||
mlua_debug_assert!(
|
mlua_debug_assert!(
|
||||||
ffi::lua_gettop(extra.ref_thread) == extra.ref_stack_max
|
ffi::lua_gettop(extra.ref_thread) == extra.ref_stack_max
|
||||||
&& extra.ref_stack_max as usize == extra.ref_free.len(),
|
&& extra.ref_stack_max as usize == extra.ref_free.len(),
|
||||||
"reference leak detected"
|
"reference leak detected"
|
||||||
);
|
);
|
||||||
*mlua_expect!(extra.registry_unref_list.lock(), "unref list poisoned") = None;
|
let mut unref_list =
|
||||||
|
mlua_expect!(extra.registry_unref_list.lock(), "unref list poisoned");
|
||||||
|
*unref_list = None;
|
||||||
ffi::lua_close(self.main_state.expect("main_state is null"));
|
ffi::lua_close(self.main_state.expect("main_state is null"));
|
||||||
if !extra.mem_info.is_null() {
|
if !extra.mem_info.is_null() {
|
||||||
Box::from_raw(extra.mem_info);
|
Box::from_raw(extra.mem_info);
|
||||||
|
@ -706,7 +708,7 @@ impl Lua {
|
||||||
self.state,
|
self.state,
|
||||||
source.as_ptr() as *const c_char,
|
source.as_ptr() as *const c_char,
|
||||||
source.len(),
|
source.len(),
|
||||||
name.map(|n| n.as_ptr()).unwrap_or_else(|| ptr::null()),
|
name.map(|n| n.as_ptr()).unwrap_or_else(ptr::null),
|
||||||
mode_str,
|
mode_str,
|
||||||
) {
|
) {
|
||||||
ffi::LUA_OK => {
|
ffi::LUA_OK => {
|
||||||
|
@ -1285,11 +1287,10 @@ impl Lua {
|
||||||
/// by `Lua::remove_registry_value`.
|
/// by `Lua::remove_registry_value`.
|
||||||
pub fn expire_registry_values(&self) {
|
pub fn expire_registry_values(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut extra = mlua_expect!(self.extra.lock(), "extra is poisoned");
|
let extra = mlua_expect!(self.extra.lock(), "extra is poisoned");
|
||||||
let unref_list = mem::replace(
|
let mut unref_list =
|
||||||
&mut *mlua_expect!(extra.registry_unref_list.lock(), "unref list poisoned"),
|
mlua_expect!(extra.registry_unref_list.lock(), "unref list poisoned");
|
||||||
Some(Vec::new()),
|
let unref_list = mem::replace(&mut *unref_list, Some(Vec::new()));
|
||||||
);
|
|
||||||
for id in mlua_expect!(unref_list, "unref list not set") {
|
for id in mlua_expect!(unref_list, "unref list not set") {
|
||||||
ffi::luaL_unref(self.state, ffi::LUA_REGISTRYINDEX, id);
|
ffi::luaL_unref(self.state, ffi::LUA_REGISTRYINDEX, id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue