@@ -694,14 +694,16 @@ impl RawLua {
694
694
695
695
/// Pops a value from the Lua stack.
696
696
///
697
- /// Uses 2 stack spaces, does not call `checkstack`.
697
+ /// Uses up to 1 stack spaces, does not call `checkstack`.
698
698
pub ( crate ) unsafe fn pop_value ( & self ) -> Value {
699
699
let value = self . stack_value ( -1 , None ) ;
700
700
ffi:: lua_pop ( self . state ( ) , 1 ) ;
701
701
value
702
702
}
703
703
704
704
/// Returns value at given stack index without popping it.
705
+ ///
706
+ /// Uses up to 1 stack spaces, does not call `checkstack`.
705
707
pub ( crate ) unsafe fn stack_value ( & self , idx : c_int , type_hint : Option < c_int > ) -> Value {
706
708
let state = self . state ( ) ;
707
709
match type_hint. unwrap_or_else ( || ffi:: lua_type ( state, idx) ) {
@@ -757,25 +759,21 @@ impl RawLua {
757
759
}
758
760
759
761
ffi:: LUA_TUSERDATA => {
760
- let ref_thread = self . ref_thread ( ) ;
761
- ffi:: lua_xpush ( state, ref_thread, idx) ;
762
-
763
762
// If the userdata is `WrappedFailure`, process it as an error or panic.
764
763
let failure_mt_ptr = ( * self . extra . get ( ) ) . wrapped_failure_mt_ptr ;
765
- match get_internal_userdata :: < WrappedFailure > ( ref_thread, -1 , failure_mt_ptr) . as_mut ( ) {
766
- Some ( WrappedFailure :: Error ( err) ) => {
767
- ffi:: lua_pop ( ref_thread, 1 ) ;
768
- Value :: Error ( Box :: new ( err. clone ( ) ) )
769
- }
764
+ match get_internal_userdata :: < WrappedFailure > ( state, idx, failure_mt_ptr) . as_mut ( ) {
765
+ Some ( WrappedFailure :: Error ( err) ) => Value :: Error ( Box :: new ( err. clone ( ) ) ) ,
770
766
Some ( WrappedFailure :: Panic ( panic) ) => {
771
- ffi:: lua_pop ( ref_thread, 1 ) ;
772
767
if let Some ( panic) = panic. take ( ) {
773
768
resume_unwind ( panic) ;
774
769
}
775
770
// Previously resumed panic?
776
771
Value :: Nil
777
772
}
778
- _ => Value :: UserData ( AnyUserData ( self . pop_ref_thread ( ) ) ) ,
773
+ _ => {
774
+ ffi:: lua_xpush ( state, self . ref_thread ( ) , idx) ;
775
+ Value :: UserData ( AnyUserData ( self . pop_ref_thread ( ) ) )
776
+ }
779
777
}
780
778
}
781
779
0 commit comments