diff options
author | Alex Orlenko <zxteam@protonmail.com> | 2020-05-12 23:34:42 +0100 |
---|---|---|
committer | Alex Orlenko <zxteam@protonmail.com> | 2020-05-15 01:48:56 +0100 |
commit | 9f2d598517937f24baa4551383c0698c8112d9fb (patch) | |
tree | ebb91c6590bccc55695c91bcc185ec732ca9aba5 /src/util.rs | |
parent | 1492790eced20ccf6f8e838b72a7c035f21dec6b (diff) | |
download | mlua-9f2d598517937f24baa4551383c0698c8112d9fb.zip |
Add clippy check and fix clippy warnings
Diffstat (limited to 'src/util.rs')
-rw-r--r-- | src/util.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/util.rs b/src/util.rs index 1d98fb7..eba93e9 100644 --- a/src/util.rs +++ b/src/util.rs @@ -57,10 +57,11 @@ impl Drop for StackGuard { fn drop(&mut self) { unsafe { let top = ffi::lua_gettop(self.state); + if top < self.top { + mlua_panic!("{} too many stack values popped", self.top - top) + } if top > self.top { ffi::lua_settop(self.state, self.top); - } else if top < self.top { - mlua_panic!("{} too many stack values popped", self.top - top); } } } @@ -473,12 +474,12 @@ pub unsafe extern "C" fn error_traceback(state: *mut ffi::lua_State) -> c_int { ); get_gc_metatable_for::<WrappedError>(state); ffi::lua_setmetatable(state, -2); - } else if let None = get_gc_userdata::<WrappedPanic>(state, -1).as_ref() { - if ffi::lua_checkstack(state, LUA_TRACEBACK_STACK) != 0 { - let s = ffi::luaL_tolstring(state, -1, ptr::null_mut()); - ffi::luaL_traceback(state, state, s, 0); - ffi::lua_remove(state, -2); - } + } else if get_gc_userdata::<WrappedPanic>(state, -1).is_null() + && ffi::lua_checkstack(state, LUA_TRACEBACK_STACK) != 0 + { + let s = ffi::luaL_tolstring(state, -1, ptr::null_mut()); + ffi::luaL_traceback(state, state, s, 0); + ffi::lua_remove(state, -2); } 1 } |