summaryrefslogtreecommitdiff
path: root/src/lua.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2020-07-28 21:05:46 +0100
committerAlex Orlenko <zxteam@protonmail.com>2020-07-28 21:10:55 +0100
commitde2c5cd9a972a009898edca79d7d576a476b4944 (patch)
treed0f58c6f3028190836dbe20772b194230d78e1f0 /src/lua.rs
parentd201beadc9b8e5e5ea028992e8e12968455a64b9 (diff)
downloadmlua-de2c5cd9a972a009898edca79d7d576a476b4944.zip
Fix compilation warnings on nightly rust
Diffstat (limited to 'src/lua.rs')
-rw-r--r--src/lua.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/lua.rs b/src/lua.rs
index 286299b..54057fc 100644
--- a/src/lua.rs
+++ b/src/lua.rs
@@ -100,13 +100,15 @@ impl Drop for Lua {
fn drop(&mut self) {
unsafe {
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!(
ffi::lua_gettop(extra.ref_thread) == extra.ref_stack_max
&& extra.ref_stack_max as usize == extra.ref_free.len(),
"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"));
if !extra.mem_info.is_null() {
Box::from_raw(extra.mem_info);
@@ -706,7 +708,7 @@ impl Lua {
self.state,
source.as_ptr() as *const c_char,
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,
) {
ffi::LUA_OK => {
@@ -1285,11 +1287,10 @@ impl Lua {
/// by `Lua::remove_registry_value`.
pub fn expire_registry_values(&self) {
unsafe {
- let mut extra = mlua_expect!(self.extra.lock(), "extra is poisoned");
- let unref_list = mem::replace(
- &mut *mlua_expect!(extra.registry_unref_list.lock(), "unref list poisoned"),
- Some(Vec::new()),
- );
+ let extra = mlua_expect!(self.extra.lock(), "extra is poisoned");
+ let mut unref_list =
+ mlua_expect!(extra.registry_unref_list.lock(), "unref list poisoned");
+ let unref_list = mem::replace(&mut *unref_list, Some(Vec::new()));
for id in mlua_expect!(unref_list, "unref list not set") {
ffi::luaL_unref(self.state, ffi::LUA_REGISTRYINDEX, id);
}