From 9f5325ef2f13cb855f8e2659647a710f78a6e948 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Sat, 22 Jul 2023 23:35:34 +0100 Subject: Use c-unwind ABI (Rust 1.71+) --- Cargo.toml | 1 + mlua-sys/src/lua51/lauxlib.rs | 4 ++-- mlua-sys/src/lua51/lua.rs | 27 +++++++++++++------------- mlua-sys/src/lua51/lualib.rs | 2 +- mlua-sys/src/lua52/lauxlib.rs | 6 +++--- mlua-sys/src/lua52/lua.rs | 33 ++++++++++++++++---------------- mlua-sys/src/lua52/lualib.rs | 2 +- mlua-sys/src/lua53/lauxlib.rs | 6 +++--- mlua-sys/src/lua53/lua.rs | 35 +++++++++++++++++----------------- mlua-sys/src/lua53/lualib.rs | 2 +- mlua-sys/src/lua54/lauxlib.rs | 6 +++--- mlua-sys/src/lua54/lua.rs | 39 +++++++++++++++++++------------------- mlua-sys/src/lua54/lualib.rs | 2 +- mlua-sys/src/luau/lauxlib.rs | 2 +- mlua-sys/src/luau/lua.rs | 42 ++++++++++++++++++++--------------------- mlua-sys/src/luau/luacode.rs | 4 +++- mlua-sys/src/luau/luacodegen.rs | 2 +- mlua-sys/src/luau/lualib.rs | 2 +- mlua_derive/src/lib.rs | 2 +- src/function.rs | 6 +++--- src/lua.rs | 16 ++++++++-------- src/luau.rs | 4 ++-- src/macros.rs | 3 ++- src/memory.rs | 2 +- src/util/mod.rs | 28 +++++++++++++-------------- tests/function.rs | 2 +- 26 files changed, 140 insertions(+), 140 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fad0b85..ccb03fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "mlua" version = "0.9.0-rc.1" # remember to update mlua_derive authors = ["Aleksandr Orlenko ", "kyren "] +rust-version = "1.71" edition = "2021" repository = "https://github.com/khvzak/mlua" documentation = "https://docs.rs/mlua" diff --git a/mlua-sys/src/lua51/lauxlib.rs b/mlua-sys/src/lua51/lauxlib.rs index 409c77f..b05b583 100644 --- a/mlua-sys/src/lua51/lauxlib.rs +++ b/mlua-sys/src/lua51/lauxlib.rs @@ -15,7 +15,7 @@ pub struct luaL_Reg { } #[cfg_attr(all(windows, raw_dylib), link(name = "lua51", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaL_register(L: *mut lua_State, libname: *const c_char, l: *const luaL_Reg); #[link_name = "luaL_getmetafield"] pub fn luaL_getmetafield_(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int; @@ -58,7 +58,7 @@ pub const LUA_NOREF: c_int = -2; pub const LUA_REFNIL: c_int = -1; #[cfg_attr(all(windows, raw_dylib), link(name = "lua51", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int; pub fn luaL_unref(L: *mut lua_State, t: c_int, r#ref: c_int); diff --git a/mlua-sys/src/lua51/lua.rs b/mlua-sys/src/lua51/lua.rs index 50fd30e..925e9c7 100644 --- a/mlua-sys/src/lua51/lua.rs +++ b/mlua-sys/src/lua51/lua.rs @@ -73,24 +73,23 @@ pub type lua_Integer = i32; pub type lua_Integer = i64; /// Type for native C functions that can be passed to Lua. -pub type lua_CFunction = unsafe extern "C" fn(L: *mut lua_State) -> c_int; +pub type lua_CFunction = unsafe extern "C-unwind" fn(L: *mut lua_State) -> c_int; // Type for functions that read/write blocks when loading/dumping Lua chunks +#[rustfmt::skip] pub type lua_Reader = - unsafe extern "C" fn(L: *mut lua_State, ud: *mut c_void, sz: *mut usize) -> *const c_char; + unsafe extern "C-unwind" fn(L: *mut lua_State, ud: *mut c_void, sz: *mut usize) -> *const c_char; +#[rustfmt::skip] pub type lua_Writer = - unsafe extern "C" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int; + unsafe extern "C-unwind" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int; /// Type for memory-allocation functions -pub type lua_Alloc = unsafe extern "C" fn( - ud: *mut c_void, - ptr: *mut c_void, - osize: usize, - nsize: usize, -) -> *mut c_void; +#[rustfmt::skip] +pub type lua_Alloc = + unsafe extern "C-unwind" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void; #[cfg_attr(all(windows, raw_dylib), link(name = "lua51", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // State manipulation // @@ -220,7 +219,7 @@ pub const LUA_GCSETPAUSE: c_int = 6; pub const LUA_GCSETSTEPMUL: c_int = 7; #[cfg_attr(all(windows, raw_dylib), link(name = "lua51", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_gc(L: *mut lua_State, what: c_int, data: c_int) -> c_int; } @@ -228,7 +227,7 @@ extern "C" { // Miscellaneous functions // #[cfg_attr(all(windows, raw_dylib), link(name = "lua51", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_error(L: *mut lua_State) -> !; pub fn lua_next(L: *mut lua_State, idx: c_int) -> c_int; pub fn lua_concat(L: *mut lua_State, n: c_int); @@ -351,10 +350,10 @@ pub const LUA_MASKLINE: c_int = 1 << (LUA_HOOKLINE as usize); pub const LUA_MASKCOUNT: c_int = 1 << (LUA_HOOKCOUNT as usize); /// Type for functions to be called on debug events. -pub type lua_Hook = unsafe extern "C" fn(L: *mut lua_State, ar: *mut lua_Debug); +pub type lua_Hook = unsafe extern "C-unwind" fn(L: *mut lua_State, ar: *mut lua_Debug); #[cfg_attr(all(windows, raw_dylib), link(name = "lua51", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_getstack(L: *mut lua_State, level: c_int, ar: *mut lua_Debug) -> c_int; pub fn lua_getinfo(L: *mut lua_State, what: *const c_char, ar: *mut lua_Debug) -> c_int; pub fn lua_getlocal(L: *mut lua_State, ar: *const lua_Debug, n: c_int) -> *const c_char; diff --git a/mlua-sys/src/lua51/lualib.rs b/mlua-sys/src/lua51/lualib.rs index e0f6d0f..9ef0b21 100644 --- a/mlua-sys/src/lua51/lualib.rs +++ b/mlua-sys/src/lua51/lualib.rs @@ -21,7 +21,7 @@ pub const LUA_JITLIBNAME: &str = "jit"; pub const LUA_FFILIBNAME: &str = "ffi"; #[cfg_attr(all(windows, raw_dylib), link(name = "lua51", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaopen_base(L: *mut lua_State) -> c_int; pub fn luaopen_table(L: *mut lua_State) -> c_int; pub fn luaopen_io(L: *mut lua_State) -> c_int; diff --git a/mlua-sys/src/lua52/lauxlib.rs b/mlua-sys/src/lua52/lauxlib.rs index 6ac3983..51da767 100644 --- a/mlua-sys/src/lua52/lauxlib.rs +++ b/mlua-sys/src/lua52/lauxlib.rs @@ -15,7 +15,7 @@ pub struct luaL_Reg { } #[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaL_checkversion_(L: *mut lua_State, ver: lua_Number); #[link_name = "luaL_getmetafield"] @@ -67,7 +67,7 @@ pub const LUA_NOREF: c_int = -2; pub const LUA_REFNIL: c_int = -1; #[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int; pub fn luaL_unref(L: *mut lua_State, t: c_int, r#ref: c_int); @@ -81,7 +81,7 @@ pub unsafe fn luaL_loadfile(L: *mut lua_State, f: *const c_char) -> c_int { } #[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaL_loadbufferx( L: *mut lua_State, buff: *const c_char, diff --git a/mlua-sys/src/lua52/lua.rs b/mlua-sys/src/lua52/lua.rs index 4e244e2..760140b 100644 --- a/mlua-sys/src/lua52/lua.rs +++ b/mlua-sys/src/lua52/lua.rs @@ -78,24 +78,23 @@ pub type lua_Integer = i64; pub type lua_Unsigned = c_uint; /// Type for native C functions that can be passed to Lua -pub type lua_CFunction = unsafe extern "C" fn(L: *mut lua_State) -> c_int; +pub type lua_CFunction = unsafe extern "C-unwind" fn(L: *mut lua_State) -> c_int; // Type for functions that read/write blocks when loading/dumping Lua chunks +#[rustfmt::skip] pub type lua_Reader = - unsafe extern "C" fn(L: *mut lua_State, ud: *mut c_void, sz: *mut usize) -> *const c_char; + unsafe extern "C-unwind" fn(L: *mut lua_State, ud: *mut c_void, sz: *mut usize) -> *const c_char; +#[rustfmt::skip] pub type lua_Writer = - unsafe extern "C" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int; + unsafe extern "C-unwind" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int; /// Type for memory-allocation functions -pub type lua_Alloc = unsafe extern "C" fn( - ud: *mut c_void, - ptr: *mut c_void, - osize: usize, - nsize: usize, -) -> *mut c_void; +#[rustfmt::skip] +pub type lua_Alloc = + unsafe extern "C-unwind" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void; #[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // State manipulation // @@ -161,14 +160,14 @@ pub const LUA_OPLT: c_int = 1; pub const LUA_OPLE: c_int = 2; #[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_arith(L: *mut lua_State, op: c_int); pub fn lua_rawequal(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int; pub fn lua_compare(L: *mut lua_State, idx1: c_int, idx2: c_int, op: c_int) -> c_int; } #[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // Push functions (C -> stack) // @@ -263,7 +262,7 @@ pub unsafe fn lua_pcall(L: *mut lua_State, n: c_int, r: c_int, f: c_int) -> c_in } #[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // Coroutine functions // @@ -300,12 +299,12 @@ pub const LUA_GCGEN: c_int = 10; pub const LUA_GCINC: c_int = 11; #[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_gc(L: *mut lua_State, what: c_int, data: c_int) -> c_int; } #[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // Miscellaneous functions // @@ -440,10 +439,10 @@ pub const LUA_MASKLINE: c_int = 1 << (LUA_HOOKLINE as usize); pub const LUA_MASKCOUNT: c_int = 1 << (LUA_HOOKCOUNT as usize); /// Type for functions to be called on debug events. -pub type lua_Hook = unsafe extern "C" fn(L: *mut lua_State, ar: *mut lua_Debug); +pub type lua_Hook = unsafe extern "C-unwind" fn(L: *mut lua_State, ar: *mut lua_Debug); #[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_getstack(L: *mut lua_State, level: c_int, ar: *mut lua_Debug) -> c_int; pub fn lua_getinfo(L: *mut lua_State, what: *const c_char, ar: *mut lua_Debug) -> c_int; pub fn lua_getlocal(L: *mut lua_State, ar: *const lua_Debug, n: c_int) -> *const c_char; diff --git a/mlua-sys/src/lua52/lualib.rs b/mlua-sys/src/lua52/lualib.rs index 271e5a5..daf1e2a 100644 --- a/mlua-sys/src/lua52/lualib.rs +++ b/mlua-sys/src/lua52/lualib.rs @@ -15,7 +15,7 @@ pub const LUA_DBLIBNAME: &str = "debug"; pub const LUA_LOADLIBNAME: &str = "package"; #[cfg_attr(all(windows, raw_dylib), link(name = "lua52", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaopen_base(L: *mut lua_State) -> c_int; pub fn luaopen_coroutine(L: *mut lua_State) -> c_int; pub fn luaopen_table(L: *mut lua_State) -> c_int; diff --git a/mlua-sys/src/lua53/lauxlib.rs b/mlua-sys/src/lua53/lauxlib.rs index 3d5b550..5002daa 100644 --- a/mlua-sys/src/lua53/lauxlib.rs +++ b/mlua-sys/src/lua53/lauxlib.rs @@ -21,7 +21,7 @@ pub struct luaL_Reg { } #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaL_checkversion_(L: *mut lua_State, ver: lua_Number, sz: usize); pub fn luaL_getmetafield(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int; @@ -69,7 +69,7 @@ pub const LUA_NOREF: c_int = -2; pub const LUA_REFNIL: c_int = -1; #[cfg_attr(all(windows, raw_dylib), link(name = "lua53", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int; pub fn luaL_unref(L: *mut lua_State, t: c_int, r#ref: c_int); @@ -83,7 +83,7 @@ pub unsafe fn luaL_loadfile(L: *mut lua_State, f: *const c_char) -> c_int { } #[cfg_attr(all(windows, raw_dylib), link(name = "lua53", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaL_loadbufferx( L: *mut lua_State, buff: *const c_char, diff --git a/mlua-sys/src/lua53/lua.rs b/mlua-sys/src/lua53/lua.rs index 3329beb..d918de4 100644 --- a/mlua-sys/src/lua53/lua.rs +++ b/mlua-sys/src/lua53/lua.rs @@ -82,28 +82,27 @@ pub type lua_Unsigned = u64; pub type lua_KContext = isize; /// Type for native C functions that can be passed to Lua -pub type lua_CFunction = unsafe extern "C" fn(L: *mut lua_State) -> c_int; +pub type lua_CFunction = unsafe extern "C-unwind" fn(L: *mut lua_State) -> c_int; /// Type for continuation functions pub type lua_KFunction = - unsafe extern "C" fn(L: *mut lua_State, status: c_int, ctx: lua_KContext) -> c_int; + unsafe extern "C-unwind" fn(L: *mut lua_State, status: c_int, ctx: lua_KContext) -> c_int; // Type for functions that read/write blocks when loading/dumping Lua chunks +#[rustfmt::skip] pub type lua_Reader = - unsafe extern "C" fn(L: *mut lua_State, ud: *mut c_void, sz: *mut usize) -> *const c_char; + unsafe extern "C-unwind" fn(L: *mut lua_State, ud: *mut c_void, sz: *mut usize) -> *const c_char; +#[rustfmt::skip] pub type lua_Writer = - unsafe extern "C" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int; + unsafe extern "C-unwind" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int; /// Type for memory-allocation functions -pub type lua_Alloc = unsafe extern "C" fn( - ud: *mut c_void, - ptr: *mut c_void, - osize: usize, - nsize: usize, -) -> *mut c_void; +#[rustfmt::skip] +pub type lua_Alloc = + unsafe extern "C-unwind" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void; #[cfg_attr(all(windows, raw_dylib), link(name = "lua53", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // State manipulation // @@ -173,14 +172,14 @@ pub const LUA_OPLT: c_int = 1; pub const LUA_OPLE: c_int = 2; #[cfg_attr(all(windows, raw_dylib), link(name = "lua53", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_arith(L: *mut lua_State, op: c_int); pub fn lua_rawequal(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int; pub fn lua_compare(L: *mut lua_State, idx1: c_int, idx2: c_int, op: c_int) -> c_int; } #[cfg_attr(all(windows, raw_dylib), link(name = "lua53", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // Push functions (C -> stack) // @@ -271,7 +270,7 @@ pub unsafe fn lua_pcall(L: *mut lua_State, n: c_int, r: c_int, f: c_int) -> c_in } #[cfg_attr(all(windows, raw_dylib), link(name = "lua53", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // Coroutine functions // @@ -306,12 +305,12 @@ pub const LUA_GCSETSTEPMUL: c_int = 7; pub const LUA_GCISRUNNING: c_int = 9; #[cfg_attr(all(windows, raw_dylib), link(name = "lua53", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_gc(L: *mut lua_State, what: c_int, data: c_int) -> c_int; } #[cfg_attr(all(windows, raw_dylib), link(name = "lua53", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // Miscellaneous functions // @@ -464,10 +463,10 @@ pub const LUA_MASKLINE: c_int = 1 << (LUA_HOOKLINE as usize); pub const LUA_MASKCOUNT: c_int = 1 << (LUA_HOOKCOUNT as usize); /// Type for functions to be called on debug events. -pub type lua_Hook = unsafe extern "C" fn(L: *mut lua_State, ar: *mut lua_Debug); +pub type lua_Hook = unsafe extern "C-unwind" fn(L: *mut lua_State, ar: *mut lua_Debug); #[cfg_attr(all(windows, raw_dylib), link(name = "lua53", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_getstack(L: *mut lua_State, level: c_int, ar: *mut lua_Debug) -> c_int; pub fn lua_getinfo(L: *mut lua_State, what: *const c_char, ar: *mut lua_Debug) -> c_int; pub fn lua_getlocal(L: *mut lua_State, ar: *const lua_Debug, n: c_int) -> *const c_char; diff --git a/mlua-sys/src/lua53/lualib.rs b/mlua-sys/src/lua53/lualib.rs index 85c18c2..5d7509e 100644 --- a/mlua-sys/src/lua53/lualib.rs +++ b/mlua-sys/src/lua53/lualib.rs @@ -16,7 +16,7 @@ pub const LUA_DBLIBNAME: &str = "debug"; pub const LUA_LOADLIBNAME: &str = "package"; #[cfg_attr(all(windows, raw_dylib), link(name = "lua53", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaopen_base(L: *mut lua_State) -> c_int; pub fn luaopen_coroutine(L: *mut lua_State) -> c_int; pub fn luaopen_table(L: *mut lua_State) -> c_int; diff --git a/mlua-sys/src/lua54/lauxlib.rs b/mlua-sys/src/lua54/lauxlib.rs index 9b85474..9ce7d0c 100644 --- a/mlua-sys/src/lua54/lauxlib.rs +++ b/mlua-sys/src/lua54/lauxlib.rs @@ -21,7 +21,7 @@ pub struct luaL_Reg { } #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaL_checkversion_(L: *mut lua_State, ver: lua_Number, sz: usize); pub fn luaL_getmetafield(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int; @@ -68,7 +68,7 @@ pub const LUA_NOREF: c_int = -2; pub const LUA_REFNIL: c_int = -1; #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaL_ref(L: *mut lua_State, t: c_int) -> c_int; pub fn luaL_unref(L: *mut lua_State, t: c_int, r#ref: c_int); @@ -82,7 +82,7 @@ pub unsafe fn luaL_loadfile(L: *mut lua_State, f: *const c_char) -> c_int { } #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaL_loadbufferx( L: *mut lua_State, buff: *const c_char, diff --git a/mlua-sys/src/lua54/lua.rs b/mlua-sys/src/lua54/lua.rs index bc04656..66633bb 100644 --- a/mlua-sys/src/lua54/lua.rs +++ b/mlua-sys/src/lua54/lua.rs @@ -81,32 +81,31 @@ pub type lua_Unsigned = u64; pub type lua_KContext = isize; /// Type for native C functions that can be passed to Lua -pub type lua_CFunction = unsafe extern "C" fn(L: *mut lua_State) -> c_int; +pub type lua_CFunction = unsafe extern "C-unwind" fn(L: *mut lua_State) -> c_int; /// Type for continuation functions pub type lua_KFunction = - unsafe extern "C" fn(L: *mut lua_State, status: c_int, ctx: lua_KContext) -> c_int; + unsafe extern "C-unwind" fn(L: *mut lua_State, status: c_int, ctx: lua_KContext) -> c_int; // Type for functions that read/write blocks when loading/dumping Lua chunks +#[rustfmt::skip] pub type lua_Reader = - unsafe extern "C" fn(L: *mut lua_State, ud: *mut c_void, sz: *mut usize) -> *const c_char; + unsafe extern "C-unwind" fn(L: *mut lua_State, ud: *mut c_void, sz: *mut usize) -> *const c_char; +#[rustfmt::skip] pub type lua_Writer = - unsafe extern "C" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int; + unsafe extern "C-unwind" fn(L: *mut lua_State, p: *const c_void, sz: usize, ud: *mut c_void) -> c_int; /// Type for memory-allocation functions -pub type lua_Alloc = unsafe extern "C" fn( - ud: *mut c_void, - ptr: *mut c_void, - osize: usize, - nsize: usize, -) -> *mut c_void; +#[rustfmt::skip] +pub type lua_Alloc = + unsafe extern "C-unwind" fn(ud: *mut c_void, ptr: *mut c_void, osize: usize, nsize: usize) -> *mut c_void; /// Type for warning functions pub type lua_WarnFunction = - unsafe extern "C" fn(ud: *mut c_void, msg: *const c_char, tocont: c_int); + unsafe extern "C-unwind" fn(ud: *mut c_void, msg: *const c_char, tocont: c_int); #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // State manipulation // @@ -180,14 +179,14 @@ pub const LUA_OPLT: c_int = 1; pub const LUA_OPLE: c_int = 2; #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_arith(L: *mut lua_State, op: c_int); pub fn lua_rawequal(L: *mut lua_State, idx1: c_int, idx2: c_int) -> c_int; pub fn lua_compare(L: *mut lua_State, idx1: c_int, idx2: c_int, op: c_int) -> c_int; } #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // Push functions (C -> stack) // @@ -278,7 +277,7 @@ pub unsafe fn lua_pcall(L: *mut lua_State, n: c_int, r: c_int, f: c_int) -> c_in } #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // Coroutine functions // @@ -307,7 +306,7 @@ pub unsafe fn lua_yield(L: *mut lua_State, n: c_int) -> c_int { // Warning-related functions // #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_setwarnf(L: *mut lua_State, f: Option, ud: *mut c_void); pub fn lua_warning(L: *mut lua_State, msg: *const c_char, tocont: c_int); } @@ -328,12 +327,12 @@ pub const LUA_GCGEN: c_int = 10; pub const LUA_GCINC: c_int = 11; #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_gc(L: *mut lua_State, what: c_int, ...) -> c_int; } #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { // // Miscellaneous functions // @@ -504,10 +503,10 @@ pub const LUA_MASKLINE: c_int = 1 << (LUA_HOOKLINE as usize); pub const LUA_MASKCOUNT: c_int = 1 << (LUA_HOOKCOUNT as usize); /// Type for functions to be called on debug events. -pub type lua_Hook = unsafe extern "C" fn(L: *mut lua_State, ar: *mut lua_Debug); +pub type lua_Hook = unsafe extern "C-unwind" fn(L: *mut lua_State, ar: *mut lua_Debug); #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn lua_getstack(L: *mut lua_State, level: c_int, ar: *mut lua_Debug) -> c_int; pub fn lua_getinfo(L: *mut lua_State, what: *const c_char, ar: *mut lua_Debug) -> c_int; pub fn lua_getlocal(L: *mut lua_State, ar: *const lua_Debug, n: c_int) -> *const c_char; diff --git a/mlua-sys/src/lua54/lualib.rs b/mlua-sys/src/lua54/lualib.rs index 876ea5b..c104375 100644 --- a/mlua-sys/src/lua54/lualib.rs +++ b/mlua-sys/src/lua54/lualib.rs @@ -15,7 +15,7 @@ pub const LUA_DBLIBNAME: &str = "debug"; pub const LUA_LOADLIBNAME: &str = "package"; #[cfg_attr(all(windows, raw_dylib), link(name = "lua54", kind = "raw-dylib"))] -extern "C" { +extern "C-unwind" { pub fn luaopen_base(L: *mut lua_State) -> c_int; pub fn luaopen_coroutine(L: *mut lua_State) -> c_int; pub fn luaopen_table(L: *mut lua_State) -> c_int; diff --git a/mlua-sys/src/luau/lauxlib.rs b/mlua-sys/src/luau/lauxlib.rs index af7d1c2..4095155 100644 --- a/mlua-sys/src/luau/lauxlib.rs +++ b/mlua-sys/src/luau/lauxlib.rs @@ -13,7 +13,7 @@ pub struct luaL_Reg { pub func: lua_CFunction, } -extern "C" { +extern "C-unwind" { pub fn luaL_register(L: *mut lua_State, libname: *const c_char, l: *const luaL_Reg); #[link_name = "luaL_getmetafield"] pub fn luaL_getmetafield_(L: *mut lua_State, obj: c_int, e: *const c_char) -> c_int; diff --git a/mlua-sys/src/luau/lua.rs b/mlua-sys/src/luau/lua.rs index d9c10ab..51168c0 100644 --- a/mlua-sys/src/luau/lua.rs +++ b/mlua-sys/src/luau/lua.rs @@ -69,15 +69,15 @@ pub type lua_Integer = c_int; pub type lua_Unsigned = c_uint; /// Type for native C functions that can be passed to Lua. -pub type lua_CFunction = unsafe extern "C" fn(L: *mut lua_State) -> c_int; -pub type lua_Continuation = unsafe extern "C" fn(L: *mut lua_State, status: c_int) -> c_int; +pub type lua_CFunction = unsafe extern "C-unwind" fn(L: *mut lua_State) -> c_int; +pub type lua_Continuation = unsafe extern "C-unwind" fn(L: *mut lua_State, status: c_int) -> c_int; /// Type for userdata destructor functions. -pub type lua_Udestructor = unsafe extern "C" fn(*mut c_void); -pub type lua_Destructor = unsafe extern "C" fn(L: *mut lua_State, *mut c_void); +pub type lua_Udestructor = unsafe extern "C-unwind" fn(*mut c_void); +pub type lua_Destructor = unsafe extern "C-unwind" fn(L: *mut lua_State, *mut c_void); /// Type for memory-allocation functions. -pub type lua_Alloc = unsafe extern "C" fn( +pub type lua_Alloc = unsafe extern "C-unwind" fn( ud: *mut c_void, ptr: *mut c_void, osize: usize, @@ -89,7 +89,7 @@ pub const fn luau_version() -> Option<&'static str> { option_env!("LUAU_VERSION") } -extern "C" { +extern "C-unwind" { // // State manipulation // @@ -251,14 +251,14 @@ pub const LUA_GCSETGOAL: c_int = 7; pub const LUA_GCSETSTEPMUL: c_int = 8; pub const LUA_GCSETSTEPSIZE: c_int = 9; -extern "C" { +extern "C-unwind" { pub fn lua_gc(L: *mut lua_State, what: c_int, data: c_int) -> c_int; } // // Memory statistics // -extern "C" { +extern "C-unwind" { pub fn lua_setmemcat(L: *mut lua_State, category: c_int); pub fn lua_totalbytes(L: *mut lua_State, category: c_int) -> usize; } @@ -266,7 +266,7 @@ extern "C" { // // Miscellaneous functions // -extern "C" { +extern "C-unwind" { pub fn lua_error(L: *mut lua_State) -> !; pub fn lua_next(L: *mut lua_State, idx: c_int) -> c_int; pub fn lua_rawiter(L: *mut lua_State, idx: c_int, iter: c_int) -> c_int; @@ -286,7 +286,7 @@ extern "C" { pub const LUA_NOREF: c_int = -1; pub const LUA_REFNIL: c_int = 0; -extern "C" { +extern "C-unwind" { pub fn lua_ref(L: *mut lua_State, idx: c_int) -> c_int; pub fn lua_unref(L: *mut lua_State, r#ref: c_int); } @@ -423,9 +423,9 @@ pub unsafe fn lua_tostring(L: *mut lua_State, i: c_int) -> *const c_char { const LUA_IDSIZE: usize = 256; /// Type for functions to be called on debug events. -pub type lua_Hook = unsafe extern "C" fn(L: *mut lua_State, ar: *mut lua_Debug); +pub type lua_Hook = unsafe extern "C-unwind" fn(L: *mut lua_State, ar: *mut lua_Debug); -pub type lua_Coverage = unsafe extern "C" fn( +pub type lua_Coverage = unsafe extern "C-unwind" fn( context: *mut c_void, function: *const c_char, linedefined: c_int, @@ -434,7 +434,7 @@ pub type lua_Coverage = unsafe extern "C" fn( size: usize, ); -extern "C" { +extern "C-unwind" { pub fn lua_stackdepth(L: *mut lua_State) -> c_int; pub fn lua_getinfo( L: *mut lua_State, @@ -492,23 +492,23 @@ pub struct lua_Callbacks { pub userdata: *mut c_void, /// gets called at safepoints (loop back edges, call/ret, gc) if set - pub interrupt: Option, + pub interrupt: Option, /// gets called when an unprotected error is raised (if longjmp is used) - pub panic: Option, + pub panic: Option, /// gets called when L is created (LP == parent) or destroyed (LP == NULL) - pub userthread: Option, + pub userthread: Option, /// gets called when a string is created; returned atom can be retrieved via tostringatom - pub useratom: Option i16>, + pub useratom: Option i16>, /// gets called when BREAK instruction is encountered - pub debugbreak: Option, + pub debugbreak: Option, /// gets called after each instruction in single step mode - pub debugstep: Option, + pub debugstep: Option, /// gets called when thread execution is interrupted by break in another thread - pub debuginterrupt: Option, + pub debuginterrupt: Option, /// gets called when protected call results in an error - pub debugprotectederror: Option, + pub debugprotectederror: Option, } extern "C" { diff --git a/mlua-sys/src/luau/luacode.rs b/mlua-sys/src/luau/luacode.rs index 571db4c..60ceaeb 100644 --- a/mlua-sys/src/luau/luacode.rs +++ b/mlua-sys/src/luau/luacode.rs @@ -13,7 +13,7 @@ pub struct lua_CompileOptions { pub mutableGlobals: *mut *const c_char, } -extern "C" { +extern "C-unwind" { #[link_name = "luau_compile"] pub fn luau_compile_( source: *const c_char, @@ -21,7 +21,9 @@ extern "C" { options: *mut lua_CompileOptions, outsize: *mut usize, ) -> *mut c_char; +} +extern "C" { fn free(p: *mut c_void); } diff --git a/mlua-sys/src/luau/luacodegen.rs b/mlua-sys/src/luau/luacodegen.rs index 56aa770..ebbddc9 100644 --- a/mlua-sys/src/luau/luacodegen.rs +++ b/mlua-sys/src/luau/luacodegen.rs @@ -4,7 +4,7 @@ use std::os::raw::c_int; use super::lua::lua_State; -extern "C" { +extern "C-unwind" { pub fn luau_codegen_supported() -> c_int; pub fn luau_codegen_create(state: *mut lua_State); pub fn luau_codegen_compile(state: *mut lua_State, idx: c_int); diff --git a/mlua-sys/src/luau/lualib.rs b/mlua-sys/src/luau/lualib.rs index 92b8642..5593f8f 100644 --- a/mlua-sys/src/luau/lualib.rs +++ b/mlua-sys/src/luau/lualib.rs @@ -13,7 +13,7 @@ pub const LUA_UTF8LIBNAME: &str = "utf8"; pub const LUA_MATHLIBNAME: &str = "math"; pub const LUA_DBLIBNAME: &str = "debug"; -extern "C" { +extern "C-unwind" { pub fn luaopen_base(L: *mut lua_State) -> c_int; pub fn luaopen_coroutine(L: *mut lua_State) -> c_int; pub fn luaopen_table(L: *mut lua_State) -> c_int; diff --git a/mlua_derive/src/lib.rs b/mlua_derive/src/lib.rs index 78937a8..55f0376 100644 --- a/mlua_derive/src/lib.rs +++ b/mlua_derive/src/lib.rs @@ -59,7 +59,7 @@ pub fn lua_module(attr: TokenStream, item: TokenStream) -> TokenStream { #func #[no_mangle] - unsafe extern "C" fn #ext_entrypoint_name(state: *mut ::mlua::lua_State) -> ::std::os::raw::c_int { + unsafe extern "C-unwind" fn #ext_entrypoint_name(state: *mut ::mlua::lua_State) -> ::std::os::raw::c_int { let lua = ::mlua::Lua::init_from_ptr(state); if #skip_memory_check { lua.skip_memory_check(true); diff --git a/src/function.rs b/src/function.rs index b992584..ac636a8 100644 --- a/src/function.rs +++ b/src/function.rs @@ -228,7 +228,7 @@ impl<'lua> Function<'lua> { /// # } /// ``` pub fn bind>(&self, args: A) -> Result> { - unsafe extern "C" fn args_wrapper_impl(state: *mut ffi::lua_State) -> c_int { + unsafe extern "C-unwind" fn args_wrapper_impl(state: *mut ffi::lua_State) -> c_int { let nargs = ffi::lua_gettop(state); let nbinds = ffi::lua_tointeger(state, ffi::lua_upvalueindex(1)) as c_int; ffi::luaL_checkstack(state, nbinds, ptr::null()); @@ -423,7 +423,7 @@ impl<'lua> Function<'lua> { #[cfg(not(feature = "luau"))] #[cfg_attr(docsrs, doc(cfg(not(feature = "luau"))))] pub fn dump(&self, strip: bool) -> Vec { - unsafe extern "C" fn writer( + unsafe extern "C-unwind" fn writer( _state: *mut ffi::lua_State, buf: *const c_void, buf_len: usize, @@ -470,7 +470,7 @@ impl<'lua> Function<'lua> { use std::ffi::CStr; use std::os::raw::c_char; - unsafe extern "C" fn callback( + unsafe extern "C-unwind" fn callback( data: *mut c_void, function: *const c_char, line_defined: c_int, diff --git a/src/lua.rs b/src/lua.rs index 64ed3f7..cf09112 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -357,7 +357,7 @@ impl Lua { { // Workaround to avoid stripping a few unused Lua symbols that could be imported // by C modules in unsafe mode - let mut _symbols: Vec<*const extern "C" fn()> = vec![ + let mut _symbols: Vec<*const extern "C-unwind" fn()> = vec![ ffi::lua_atpanic as _, ffi::lua_isuserdata as _, ffi::lua_tocfunction as _, @@ -885,7 +885,7 @@ impl Lua { ) where F: Fn(&Lua, Debug) -> Result<()> + MaybeSend + 'static, { - unsafe extern "C" fn hook_proc(state: *mut ffi::lua_State, ar: *mut ffi::lua_Debug) { + unsafe extern "C-unwind" fn hook_proc(state: *mut ffi::lua_State, ar: *mut ffi::lua_Debug) { let extra = extra_data(state); if (*extra).hook_thread != state { // Hook was destined for a different thread, ignore @@ -979,7 +979,7 @@ impl Lua { where F: Fn(&Lua) -> Result + MaybeSend + 'static, { - unsafe extern "C" fn interrupt_proc(state: *mut ffi::lua_State, gc: c_int) { + unsafe extern "C-unwind" fn interrupt_proc(state: *mut ffi::lua_State, gc: c_int) { if gc >= 0 { // We don't support GC interrupts since they cannot survive Lua exceptions return; @@ -1031,7 +1031,7 @@ impl Lua { where F: Fn(&Lua, &str, bool) -> Result<()> + MaybeSend + 'static, { - unsafe extern "C" fn warn_proc(ud: *mut c_void, msg: *const c_char, tocont: c_int) { + unsafe extern "C-unwind" fn warn_proc(ud: *mut c_void, msg: *const c_char, tocont: c_int) { let extra = ud as *mut ExtraData; let lua: &Lua = mem::transmute((*extra).inner.assume_init_ref()); callback_error_ext(lua.state(), extra, |_| { @@ -2736,7 +2736,7 @@ impl Lua { &'lua self, func: Callback<'lua, 'static>, ) -> Result> { - unsafe extern "C" fn call_callback(state: *mut ffi::lua_State) -> c_int { + unsafe extern "C-unwind" fn call_callback(state: *mut ffi::lua_State) -> c_int { // Normal functions can be scoped and therefore destroyed, // so we need to check that the first upvalue is valid let (upvalue, extra) = match ffi::lua_type(state, ffi::lua_upvalueindex(1)) { @@ -2814,7 +2814,7 @@ impl Lua { } } - unsafe extern "C" fn call_callback(state: *mut ffi::lua_State) -> c_int { + unsafe extern "C-unwind" fn call_callback(state: *mut ffi::lua_State) -> c_int { // Async functions cannot be scoped and therefore destroyed, // so the first upvalue is always valid let upvalue = get_userdata::(state, ffi::lua_upvalueindex(1)); @@ -2847,7 +2847,7 @@ impl Lua { }) } - unsafe extern "C" fn poll_future(state: *mut ffi::lua_State) -> c_int { + unsafe extern "C-unwind" fn poll_future(state: *mut ffi::lua_State) -> c_int { let upvalue = get_userdata::(state, ffi::lua_upvalueindex(1)); let extra = (*upvalue).extra.get(); callback_error_ext(state, extra, |_| { @@ -2903,7 +2903,7 @@ impl Lua { Function(self.pop_ref()) }; - unsafe extern "C" fn unpack(state: *mut ffi::lua_State) -> c_int { + unsafe extern "C-unwind" fn unpack(state: *mut ffi::lua_State) -> c_int { let len = ffi::lua_tointeger(state, 2); ffi::luaL_checkstack(state, len as c_int, ptr::null()); for i in 1..=len { diff --git a/src/luau.rs b/src/luau.rs index 58c9851..e17296e 100644 --- a/src/luau.rs +++ b/src/luau.rs @@ -32,7 +32,7 @@ impl Lua { } } -unsafe extern "C" fn lua_collectgarbage(state: *mut ffi::lua_State) -> c_int { +unsafe extern "C-unwind" fn lua_collectgarbage(state: *mut ffi::lua_State) -> c_int { let option = ffi::luaL_optstring(state, 1, cstr!("collect")); let option = CStr::from_ptr(option); let arg = ffi::luaL_optinteger(state, 2, 0); @@ -122,7 +122,7 @@ fn lua_require(lua: &Lua, name: Option) -> Result { } // Luau vector datatype constructor -unsafe extern "C" fn lua_vector(state: *mut ffi::lua_State) -> c_int { +unsafe extern "C-unwind" fn lua_vector(state: *mut ffi::lua_State) -> c_int { let x = ffi::luaL_checknumber(state, 1) as c_float; let y = ffi::luaL_checknumber(state, 2) as c_float; let z = ffi::luaL_checknumber(state, 3) as c_float; diff --git a/src/macros.rs b/src/macros.rs index 38c7726..b3c991b 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -101,7 +101,8 @@ macro_rules! protect_lua { }; ($state:expr, $nargs:expr, $nresults:expr, fn($state_inner:ident) $code:expr) => {{ - unsafe extern "C" fn do_call($state_inner: *mut ffi::lua_State) -> ::std::os::raw::c_int { + use ::std::os::raw::c_int; + unsafe extern "C-unwind" fn do_call($state_inner: *mut ffi::lua_State) -> c_int { $code; let nresults = $nresults; if nresults == ::ffi::LUA_MULTRET { diff --git a/src/memory.rs b/src/memory.rs index ad30a79..e199a75 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -85,7 +85,7 @@ impl MemoryState { } } -unsafe extern "C" fn allocator( +unsafe extern "C-unwind" fn allocator( extra: *mut c_void, ptr: *mut c_void, osize: usize, diff --git a/src/util/mod.rs b/src/util/mod.rs index b125413..d52119f 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -88,7 +88,7 @@ impl Drop for StackGuard { pub unsafe fn protect_lua_call( state: *mut ffi::lua_State, nargs: c_int, - f: unsafe extern "C" fn(*mut ffi::lua_State) -> c_int, + f: unsafe extern "C-unwind" fn(*mut ffi::lua_State) -> c_int, ) -> Result<()> { let stack_start = ffi::lua_gettop(state) - nargs; @@ -133,7 +133,7 @@ where nresults: c_int, } - unsafe extern "C" fn do_call(state: *mut ffi::lua_State) -> c_int + unsafe extern "C-unwind" fn do_call(state: *mut ffi::lua_State) -> c_int where F: Fn(*mut ffi::lua_State) -> R, R: Copy, @@ -295,7 +295,7 @@ pub unsafe fn push_userdata(state: *mut ffi::lua_State, t: T, protect: bool) #[cfg(feature = "luau")] #[inline] pub unsafe fn push_userdata(state: *mut ffi::lua_State, t: T, protect: bool) -> Result<()> { - unsafe extern "C" fn destructor(ud: *mut c_void) { + unsafe extern "C-unwind" fn destructor(ud: *mut c_void) { ptr::drop_in_place(ud as *mut T); } @@ -400,16 +400,16 @@ pub unsafe fn get_gc_userdata( ud } -unsafe extern "C" fn lua_error_impl(state: *mut ffi::lua_State) -> c_int { +unsafe extern "C-unwind" fn lua_error_impl(state: *mut ffi::lua_State) -> c_int { ffi::lua_error(state); } -unsafe extern "C" fn lua_isfunction_impl(state: *mut ffi::lua_State) -> c_int { +unsafe extern "C-unwind" fn lua_isfunction_impl(state: *mut ffi::lua_State) -> c_int { ffi::lua_pushboolean(state, ffi::lua_isfunction(state, -1)); 1 } -unsafe extern "C" fn lua_istable_impl(state: *mut ffi::lua_State) -> c_int { +unsafe extern "C-unwind" fn lua_istable_impl(state: *mut ffi::lua_State) -> c_int { ffi::lua_pushboolean(state, ffi::lua_istable(state, -1)); 1 } @@ -613,7 +613,7 @@ pub unsafe fn init_userdata_metatable( } #[cfg(not(feature = "luau"))] -pub unsafe extern "C" fn userdata_destructor(state: *mut ffi::lua_State) -> c_int { +pub unsafe extern "C-unwind" fn userdata_destructor(state: *mut ffi::lua_State) -> c_int { // It's probably NOT a good idea to catch Rust panics in finalizer // Lua 5.4 ignores it, other versions generates `LUA_ERRGCMM` without calling message handler take_userdata::(state); @@ -685,7 +685,7 @@ where } } -pub unsafe extern "C" fn error_traceback(state: *mut ffi::lua_State) -> c_int { +pub unsafe extern "C-unwind" fn error_traceback(state: *mut ffi::lua_State) -> c_int { // Luau calls error handler for memory allocation errors, skip it // See https://github.com/Roblox/luau/issues/880 #[cfg(feature = "luau")] @@ -725,7 +725,7 @@ pub unsafe fn error_traceback_thread(state: *mut ffi::lua_State, thread: *mut ff } // A variant of `pcall` that does not allow Lua to catch Rust panics from `callback_error`. -pub unsafe extern "C" fn safe_pcall(state: *mut ffi::lua_State) -> c_int { +pub unsafe extern "C-unwind" fn safe_pcall(state: *mut ffi::lua_State) -> c_int { ffi::luaL_checkstack(state, 2, ptr::null()); let top = ffi::lua_gettop(state); @@ -751,8 +751,8 @@ pub unsafe extern "C" fn safe_pcall(state: *mut ffi::lua_State) -> c_int { } // A variant of `xpcall` that does not allow Lua to catch Rust panics from `callback_error`. -pub unsafe extern "C" fn safe_xpcall(state: *mut ffi::lua_State) -> c_int { - unsafe extern "C" fn xpcall_msgh(state: *mut ffi::lua_State) -> c_int { +pub unsafe extern "C-unwind" fn safe_xpcall(state: *mut ffi::lua_State) -> c_int { + unsafe extern "C-unwind" fn xpcall_msgh(state: *mut ffi::lua_State) -> c_int { ffi::luaL_checkstack(state, 2, ptr::null()); if let Some(WrappedFailure::Panic(_)) = @@ -866,7 +866,7 @@ pub unsafe fn init_error_registry(state: *mut ffi::lua_State) -> Result<()> { // Create error and panic metatables - unsafe extern "C" fn error_tostring(state: *mut ffi::lua_State) -> c_int { + unsafe extern "C-unwind" fn error_tostring(state: *mut ffi::lua_State) -> c_int { callback_error(state, |_| { check_stack(state, 3)?; @@ -924,7 +924,7 @@ pub unsafe fn init_error_registry(state: *mut ffi::lua_State) -> Result<()> { // Create destructed userdata metatable - unsafe extern "C" fn destructed_error(state: *mut ffi::lua_State) -> c_int { + unsafe extern "C-unwind" fn destructed_error(state: *mut ffi::lua_State) -> c_int { callback_error(state, |_| Err(Error::CallbackDestructed)) } @@ -1007,7 +1007,7 @@ impl WrappedFailure { let size = mem::size_of::(); #[cfg(feature = "luau")] let ud = { - unsafe extern "C" fn destructor(p: *mut c_void) { + unsafe extern "C-unwind" fn destructor(p: *mut c_void) { ptr::drop_in_place(p as *mut WrappedFailure); } ffi::lua_newuserdatadtor(state, size, destructor) as *mut Self diff --git a/tests/function.rs b/tests/function.rs index 83325a6..48efb8b 100644 --- a/tests/function.rs +++ b/tests/function.rs @@ -86,7 +86,7 @@ fn test_rust_function() -> Result<()> { fn test_c_function() -> Result<()> { let lua = Lua::new(); - unsafe extern "C" fn c_function(state: *mut mlua::lua_State) -> std::os::raw::c_int { + unsafe extern "C-unwind" fn c_function(state: *mut mlua::lua_State) -> std::os::raw::c_int { let lua = Lua::init_from_ptr(state); lua.globals().set("c_function", true).unwrap(); 0 -- cgit v1.2.3