@@ -9,9 +9,8 @@ use std::sync::Arc;
99use crate :: error:: { Error , Result } ;
1010use crate :: memory:: MemoryState ;
1111use crate :: util:: {
12- check_stack, get_internal_metatable, get_internal_userdata, init_internal_metatable,
13- push_internal_userdata, push_string, push_table, rawset_field, to_string, TypeKey ,
14- DESTRUCTED_USERDATA_METATABLE ,
12+ check_stack, get_internal_userdata, init_internal_metatable, push_internal_userdata, push_string,
13+ push_table, rawset_field, to_string, TypeKey , DESTRUCTED_USERDATA_METATABLE ,
1514} ;
1615
1716static WRAPPED_FAILURE_TYPE_KEY : u8 = 0 ;
@@ -31,12 +30,8 @@ impl TypeKey for WrappedFailure {
3130
3231impl WrappedFailure {
3332 pub ( crate ) unsafe fn new_userdata ( state : * mut ffi:: lua_State ) -> * mut Self {
34- #[ cfg( feature = "luau" ) ]
35- let ud = ffi:: lua_newuserdata_t :: < Self > ( state) ;
36- #[ cfg( not( feature = "luau" ) ) ]
37- let ud = ffi:: lua_newuserdata ( state, std:: mem:: size_of :: < Self > ( ) ) as * mut Self ;
38- ptr:: write ( ud, WrappedFailure :: None ) ;
39- ud
33+ // Unprotected calls always return `Ok`
34+ push_internal_userdata ( state, WrappedFailure :: None , false ) . unwrap ( )
4035 }
4136}
4237
@@ -90,16 +85,11 @@ where
9085 let cause = Arc :: new ( err) ;
9186 let wrapped_error = WrappedFailure :: Error ( Error :: CallbackError { traceback, cause } ) ;
9287 ptr:: write ( ud, wrapped_error) ;
93- get_internal_metatable :: < WrappedFailure > ( state) ;
94- ffi:: lua_setmetatable ( state, -2 ) ;
95-
9688 ffi:: lua_error ( state)
9789 }
9890 Err ( p) => {
9991 ffi:: lua_settop ( state, 1 ) ;
10092 ptr:: write ( ud, WrappedFailure :: Panic ( Some ( p) ) ) ;
101- get_internal_metatable :: < WrappedFailure > ( state) ;
102- ffi:: lua_setmetatable ( state, -2 ) ;
10393 ffi:: lua_error ( state)
10494 }
10595 }
0 commit comments