@@ -205,7 +205,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
205205 false
206206 }
207207
208- pub ( crate ) fn str_to_value ( & mut self , s : & str ) -> EvalResult < ' tcx , Value > {
208+ pub fn str_to_value ( & mut self , s : & str ) -> EvalResult < ' tcx , Value > {
209209 let ptr = self . memory . allocate_cached ( s. as_bytes ( ) ) ?;
210210 Ok ( Value :: ByValPair ( PrimVal :: Ptr ( ptr) , PrimVal :: from_u128 ( s. len ( ) as u128 ) ) )
211211 }
@@ -363,11 +363,11 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
363363 self . tcx . normalize_associated_type ( & f. ty ( self . tcx , param_substs) )
364364 }
365365
366- pub ( super ) fn type_size ( & self , ty : Ty < ' tcx > ) -> EvalResult < ' tcx , Option < u64 > > {
366+ pub fn type_size ( & self , ty : Ty < ' tcx > ) -> EvalResult < ' tcx , Option < u64 > > {
367367 self . type_size_with_substs ( ty, self . substs ( ) )
368368 }
369369
370- pub ( super ) fn type_align ( & self , ty : Ty < ' tcx > ) -> EvalResult < ' tcx , u64 > {
370+ pub fn type_align ( & self , ty : Ty < ' tcx > ) -> EvalResult < ' tcx , u64 > {
371371 self . type_align_with_substs ( ty, self . substs ( ) )
372372 }
373373
@@ -1000,39 +1000,6 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
10001000 }
10011001 }
10021002
1003- pub ( super ) fn wrapping_pointer_offset ( & self , ptr : Pointer , pointee_ty : Ty < ' tcx > , offset : i64 ) -> EvalResult < ' tcx , Pointer > {
1004- // FIXME: assuming here that type size is < i64::max_value()
1005- let pointee_size = self . type_size ( pointee_ty) ?. expect ( "cannot offset a pointer to an unsized type" ) as i64 ;
1006- let offset = offset. overflowing_mul ( pointee_size) . 0 ;
1007- ptr. wrapping_signed_offset ( offset, self )
1008- }
1009-
1010- pub fn pointer_offset ( & self , ptr : Pointer , pointee_ty : Ty < ' tcx > , offset : i64 ) -> EvalResult < ' tcx , Pointer > {
1011- // This function raises an error if the offset moves the pointer outside of its allocation. We consider
1012- // ZSTs their own huge allocation that doesn't overlap with anything (and nothing moves in there because the size is 0).
1013- // We also consider the NULL pointer its own separate allocation, and all the remaining integers pointers their own
1014- // allocation.
1015-
1016- if ptr. is_null ( ) ? { // NULL pointers must only be offset by 0
1017- return if offset == 0 { Ok ( ptr) } else { Err ( EvalError :: InvalidNullPointerUsage ) } ;
1018- }
1019- // FIXME: assuming here that type size is < i64::max_value()
1020- let pointee_size = self . type_size ( pointee_ty) ?. expect ( "cannot offset a pointer to an unsized type" ) as i64 ;
1021- return if let Some ( offset) = offset. checked_mul ( pointee_size) {
1022- let ptr = ptr. signed_offset ( offset, self ) ?;
1023- // Do not do bounds-checking for integers; they can never alias a normal pointer anyway.
1024- if let PrimVal :: Ptr ( ptr) = ptr. into_inner_primval ( ) {
1025- self . memory . check_bounds ( ptr, false ) ?;
1026- } else if ptr. is_null ( ) ? {
1027- // We moved *to* a NULL pointer. That seems wrong, LLVM considers the NULL pointer its own small allocation. Reject this, for now.
1028- return Err ( EvalError :: InvalidNullPointerUsage ) ;
1029- }
1030- Ok ( ptr)
1031- } else {
1032- Err ( EvalError :: OverflowingMath )
1033- }
1034- }
1035-
10361003 pub ( super ) fn eval_operand_to_primval ( & mut self , op : & mir:: Operand < ' tcx > ) -> EvalResult < ' tcx , PrimVal > {
10371004 let value = self . eval_operand ( op) ?;
10381005 let ty = self . operand_ty ( op) ;
@@ -1081,7 +1048,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
10811048 Ok ( ( ) )
10821049 }
10831050
1084- pub ( super ) fn force_allocation (
1051+ pub fn force_allocation (
10851052 & mut self ,
10861053 lvalue : Lvalue < ' tcx > ,
10871054 ) -> EvalResult < ' tcx , Lvalue < ' tcx > > {
@@ -1275,7 +1242,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
12751242 Ok ( ( ) )
12761243 }
12771244
1278- pub ( super ) fn write_value_to_ptr (
1245+ pub fn write_value_to_ptr (
12791246 & mut self ,
12801247 value : Value ,
12811248 dest : Pointer ,
@@ -1293,7 +1260,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
12931260 }
12941261 }
12951262
1296- pub ( super ) fn write_pair_to_ptr (
1263+ pub fn write_pair_to_ptr (
12971264 & mut self ,
12981265 a : PrimVal ,
12991266 b : PrimVal ,
@@ -1416,7 +1383,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
14161383 }
14171384 }
14181385
1419- pub ( super ) fn read_value ( & mut self , ptr : Pointer , ty : Ty < ' tcx > ) -> EvalResult < ' tcx , Value > {
1386+ pub fn read_value ( & mut self , ptr : Pointer , ty : Ty < ' tcx > ) -> EvalResult < ' tcx , Value > {
14201387 if let Some ( val) = self . try_read_value ( ptr, ty) ? {
14211388 Ok ( val)
14221389 } else {
0 commit comments