summaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2020-05-12 23:34:42 +0100
committerAlex Orlenko <zxteam@protonmail.com>2020-05-15 01:48:56 +0100
commit9f2d598517937f24baa4551383c0698c8112d9fb (patch)
treeebb91c6590bccc55695c91bcc185ec732ca9aba5 /src/util.rs
parent1492790eced20ccf6f8e838b72a7c035f21dec6b (diff)
downloadmlua-9f2d598517937f24baa4551383c0698c8112d9fb.zip
Add clippy check and fix clippy warnings
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs17
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
}