@@ -123,10 +123,7 @@ impl<'a> VM<'a> {
123123 self . source . push ( '\n' ) ;
124124
125125 let function = Compiler :: compile ( source, offset, & mut self . gc ) ?;
126- match self . run_function ( function) {
127- Ok ( ( ) ) | Err ( ( Error :: Halt , _) ) => Ok ( ( ) ) ,
128- Err ( e) => Err ( vec ! [ e] ) ,
129- }
126+ self . run_function ( function) . map_err ( |e| vec ! [ e] )
130127 }
131128
132129 fn run_function ( & mut self , function : * mut ObjectFunction ) -> Result < ( ) > {
@@ -272,15 +269,15 @@ impl<'a> VM<'a> {
272269
273270 fn op_get_upvalue ( & mut self , ip : & mut * const u8 ) -> Result < ( ) > {
274271 let upvalue_idx = Self :: read_u8 ( ip) as usize ;
275- let object = * unsafe { ( & ( * self . frame . closure ) . upvalues ) . get_unchecked ( upvalue_idx) } ;
272+ let object = * unsafe { ( * self . frame . closure ) . upvalues . get_unchecked ( upvalue_idx) } ;
276273 let value = unsafe { * ( * object) . location } ;
277274 self . push ( value) ;
278275 become self. dispatch ( ip)
279276 }
280277
281278 fn op_set_upvalue ( & mut self , ip : & mut * const u8 ) -> Result < ( ) > {
282279 let upvalue_idx = Self :: read_u8 ( ip) as usize ;
283- let object = * unsafe { ( & ( * self . frame . closure ) . upvalues ) . get_unchecked ( upvalue_idx) } ;
280+ let object = * unsafe { ( * self . frame . closure ) . upvalues . get_unchecked ( upvalue_idx) } ;
284281 let value = unsafe { ( * object) . location } ;
285282 unsafe { * value = * self . peek ( 0 ) } ;
286283 become self. dispatch ( ip)
@@ -566,7 +563,7 @@ impl<'a> VM<'a> {
566563 let location = unsafe { self . frame . stack . add ( upvalue_idx) } ;
567564 self . capture_upvalue ( location)
568565 } else {
569- * unsafe { ( & ( * self . frame . closure ) . upvalues ) . get_unchecked ( upvalue_idx) }
566+ * unsafe { ( * self . frame . closure ) . upvalues . get_unchecked ( upvalue_idx) }
570567 } ;
571568 upvalues. push ( upvalue) ;
572569 }
@@ -595,7 +592,7 @@ impl<'a> VM<'a> {
595592 self . push ( value) ;
596593 become self. dispatch ( ip)
597594 }
598- None => Err ( ( Error :: Halt , 0 .. 0 ) ) ,
595+ None => Ok ( ( ) ) ,
599596 }
600597 }
601598
@@ -811,7 +808,7 @@ impl<'a> VM<'a> {
811808 fn read_value ( & self , ip : & mut * const u8 ) -> Value {
812809 let constant_idx = Self :: read_u8 ( ip) as usize ;
813810 let function = unsafe { ( * self . frame . closure ) . function } ;
814- * unsafe { ( & ( * function) . chunk . constants ) . get_unchecked ( constant_idx) }
811+ * unsafe { ( * function) . chunk . constants . get_unchecked ( constant_idx) }
815812 }
816813
817814 /// Pushes a [`Value`] to the stack.
0 commit comments