@@ -45,7 +45,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
45
45
46
46
"arith_offset" => {
47
47
let offset = self . value_to_primval ( arg_vals[ 1 ] , isize) ?. to_i128 ( ) ? as i64 ;
48
- let ptr = arg_vals[ 0 ] . into_ptr ( & mut self . memory ) ?;
48
+ let ptr = arg_vals[ 0 ] . into_ptr ( & self . memory ) ?;
49
49
let result_ptr = self . wrapping_pointer_offset ( ptr, substs. type_at ( 0 ) , offset) ?;
50
50
self . write_ptr ( dest, result_ptr, dest_ty) ?;
51
51
}
@@ -61,7 +61,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
61
61
"atomic_load_acq" |
62
62
"volatile_load" => {
63
63
let ty = substs. type_at ( 0 ) ;
64
- let ptr = arg_vals[ 0 ] . into_ptr ( & mut self . memory ) ?;
64
+ let ptr = arg_vals[ 0 ] . into_ptr ( & self . memory ) ?;
65
65
self . write_value ( Value :: by_ref ( ptr) , dest, ty) ?;
66
66
}
67
67
@@ -70,7 +70,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
70
70
"atomic_store_rel" |
71
71
"volatile_store" => {
72
72
let ty = substs. type_at ( 0 ) ;
73
- let dest = arg_vals[ 0 ] . into_ptr ( & mut self . memory ) ?;
73
+ let dest = arg_vals[ 0 ] . into_ptr ( & self . memory ) ?;
74
74
self . write_value_to_ptr ( arg_vals[ 1 ] , dest, ty) ?;
75
75
}
76
76
@@ -80,12 +80,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
80
80
81
81
_ if intrinsic_name. starts_with ( "atomic_xchg" ) => {
82
82
let ty = substs. type_at ( 0 ) ;
83
- let ptr = arg_vals[ 0 ] . into_ptr ( & mut self . memory ) ?;
83
+ let ptr = arg_vals[ 0 ] . into_ptr ( & self . memory ) ?;
84
84
let change = self . value_to_primval ( arg_vals[ 1 ] , ty) ?;
85
85
let old = self . read_value ( ptr, ty) ?;
86
86
let old = match old {
87
87
Value :: ByVal ( val) => val,
88
- Value :: ByRef ( .. ) => bug ! ( "just read the value, can't be byref" ) ,
88
+ Value :: ByRef { .. } => bug ! ( "just read the value, can't be byref" ) ,
89
89
Value :: ByValPair ( ..) => bug ! ( "atomic_xchg doesn't work with nonprimitives" ) ,
90
90
} ;
91
91
self . write_primval ( dest, old, ty) ?;
@@ -94,13 +94,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
94
94
95
95
_ if intrinsic_name. starts_with ( "atomic_cxchg" ) => {
96
96
let ty = substs. type_at ( 0 ) ;
97
- let ptr = arg_vals[ 0 ] . into_ptr ( & mut self . memory ) ?;
97
+ let ptr = arg_vals[ 0 ] . into_ptr ( & self . memory ) ?;
98
98
let expect_old = self . value_to_primval ( arg_vals[ 1 ] , ty) ?;
99
99
let change = self . value_to_primval ( arg_vals[ 2 ] , ty) ?;
100
100
let old = self . read_value ( ptr, ty) ?;
101
101
let old = match old {
102
102
Value :: ByVal ( val) => val,
103
- Value :: ByRef ( .. ) => bug ! ( "just read the value, can't be byref" ) ,
103
+ Value :: ByRef { .. } => bug ! ( "just read the value, can't be byref" ) ,
104
104
Value :: ByValPair ( ..) => bug ! ( "atomic_cxchg doesn't work with nonprimitives" ) ,
105
105
} ;
106
106
let ( val, _) = self . binary_op ( mir:: BinOp :: Eq , old, ty, expect_old, ty) ?;
@@ -115,12 +115,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
115
115
"atomic_xadd" | "atomic_xadd_acq" | "atomic_xadd_rel" | "atomic_xadd_acqrel" | "atomic_xadd_relaxed" |
116
116
"atomic_xsub" | "atomic_xsub_acq" | "atomic_xsub_rel" | "atomic_xsub_acqrel" | "atomic_xsub_relaxed" => {
117
117
let ty = substs. type_at ( 0 ) ;
118
- let ptr = arg_vals[ 0 ] . into_ptr ( & mut self . memory ) ?;
118
+ let ptr = arg_vals[ 0 ] . into_ptr ( & self . memory ) ?;
119
119
let change = self . value_to_primval ( arg_vals[ 1 ] , ty) ?;
120
120
let old = self . read_value ( ptr, ty) ?;
121
121
let old = match old {
122
122
Value :: ByVal ( val) => val,
123
- Value :: ByRef ( .. ) => bug ! ( "just read the value, can't be byref" ) ,
123
+ Value :: ByRef { .. } => bug ! ( "just read the value, can't be byref" ) ,
124
124
Value :: ByValPair ( ..) => bug ! ( "atomic_xadd_relaxed doesn't work with nonprimitives" ) ,
125
125
} ;
126
126
self . write_primval ( dest, old, ty) ?;
@@ -148,8 +148,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
148
148
// TODO: We do not even validate alignment for the 0-bytes case. libstd relies on this in vec::IntoIter::next.
149
149
// Also see the write_bytes intrinsic.
150
150
let elem_align = self . type_align ( elem_ty) ?;
151
- let src = arg_vals[ 0 ] . into_ptr ( & mut self . memory ) ?;
152
- let dest = arg_vals[ 1 ] . into_ptr ( & mut self . memory ) ?;
151
+ let src = arg_vals[ 0 ] . into_ptr ( & self . memory ) ?;
152
+ let dest = arg_vals[ 1 ] . into_ptr ( & self . memory ) ?;
153
153
self . memory . copy ( src, dest, count * elem_size, elem_align, intrinsic_name. ends_with ( "_nonoverlapping" ) ) ?;
154
154
}
155
155
}
@@ -176,7 +176,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
176
176
177
177
"discriminant_value" => {
178
178
let ty = substs. type_at ( 0 ) ;
179
- let adt_ptr = arg_vals[ 0 ] . into_ptr ( & mut self . memory ) ?. to_ptr ( ) ?;
179
+ let adt_ptr = arg_vals[ 0 ] . into_ptr ( & self . memory ) ?. to_ptr ( ) ?;
180
180
let discr_val = self . read_discriminant_value ( adt_ptr, ty) ?;
181
181
self . write_primval ( dest, PrimVal :: Bytes ( discr_val) , dest_ty) ?;
182
182
}
@@ -251,10 +251,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
251
251
let size = self . type_size ( dest_ty) ?. expect ( "cannot zero unsized value" ) ;
252
252
let init = |this : & mut Self , val : Value | {
253
253
let zero_val = match val {
254
- Value :: ByRef ( ptr, aligned) => {
254
+ Value :: ByRef { ptr, aligned } => {
255
255
// These writes have no alignment restriction anyway.
256
256
this. memory . write_repeat ( ptr, 0 , size) ?;
257
- Value :: ByRef ( ptr, aligned)
257
+ Value :: ByRef { ptr, aligned }
258
258
} ,
259
259
// TODO(solson): Revisit this, it's fishy to check for Undef here.
260
260
Value :: ByVal ( PrimVal :: Undef ) => match this. ty_to_primval_kind ( dest_ty) {
@@ -297,7 +297,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
297
297
298
298
"move_val_init" => {
299
299
let ty = substs. type_at ( 0 ) ;
300
- let ptr = arg_vals[ 0 ] . into_ptr ( & mut self . memory ) ?;
300
+ let ptr = arg_vals[ 0 ] . into_ptr ( & self . memory ) ?;
301
301
self . write_value_to_ptr ( arg_vals[ 1 ] , ptr, ty) ?;
302
302
}
303
303
@@ -310,7 +310,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
310
310
311
311
"offset" => {
312
312
let offset = self . value_to_primval ( arg_vals[ 1 ] , isize) ?. to_i128 ( ) ? as i64 ;
313
- let ptr = arg_vals[ 0 ] . into_ptr ( & mut self . memory ) ?;
313
+ let ptr = arg_vals[ 0 ] . into_ptr ( & self . memory ) ?;
314
314
let result_ptr = self . pointer_offset ( ptr, substs. type_at ( 0 ) , offset) ?;
315
315
self . write_ptr ( dest, result_ptr, dest_ty) ?;
316
316
}
@@ -399,7 +399,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
399
399
"transmute" => {
400
400
let src_ty = substs. type_at ( 0 ) ;
401
401
let ptr = self . force_allocation ( dest) ?. to_ptr ( ) ?;
402
- self . write_maybe_aligned ( /*aligned*/ false , |ectx| {
402
+ self . write_maybe_aligned_mut ( /*aligned*/ false , |ectx| {
403
403
ectx. write_value_to_ptr ( arg_vals[ 0 ] , ptr. into ( ) , src_ty)
404
404
} ) ?;
405
405
}
@@ -442,9 +442,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
442
442
let size = dest_layout. size ( & self . tcx . data_layout ) . bytes ( ) ;
443
443
let uninit = |this : & mut Self , val : Value | {
444
444
match val {
445
- Value :: ByRef ( ptr, aligned) => {
445
+ Value :: ByRef { ptr, aligned } => {
446
446
this. memory . mark_definedness ( ptr, size, false ) ?;
447
- Ok ( Value :: ByRef ( ptr, aligned) )
447
+ Ok ( Value :: ByRef { ptr, aligned } )
448
448
} ,
449
449
_ => Ok ( Value :: ByVal ( PrimVal :: Undef ) ) ,
450
450
}
@@ -464,7 +464,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
464
464
let ty_align = self . type_align ( ty) ?;
465
465
let val_byte = self . value_to_primval ( arg_vals[ 1 ] , u8) ?. to_u128 ( ) ? as u8 ;
466
466
let size = self . type_size ( ty) ?. expect ( "write_bytes() type must be sized" ) ;
467
- let ptr = arg_vals[ 0 ] . into_ptr ( & mut self . memory ) ?;
467
+ let ptr = arg_vals[ 0 ] . into_ptr ( & self . memory ) ?;
468
468
let count = self . value_to_primval ( arg_vals[ 2 ] , usize) ?. to_u64 ( ) ?;
469
469
if count > 0 {
470
470
// HashMap relies on write_bytes on a NULL ptr with count == 0 to work
@@ -550,15 +550,15 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
550
550
Ok ( ( size, align. abi ( ) ) )
551
551
}
552
552
ty:: TyDynamic ( ..) => {
553
- let ( _, vtable) = value. into_ptr_vtable_pair ( & mut self . memory ) ?;
553
+ let ( _, vtable) = value. into_ptr_vtable_pair ( & self . memory ) ?;
554
554
// the second entry in the vtable is the dynamic size of the object.
555
555
self . read_size_and_align_from_vtable ( vtable)
556
556
}
557
557
558
558
ty:: TySlice ( _) | ty:: TyStr => {
559
559
let elem_ty = ty. sequence_element_type ( self . tcx ) ;
560
560
let elem_size = self . type_size ( elem_ty) ?. expect ( "slice element must be sized" ) as u64 ;
561
- let ( _, len) = value. into_slice ( & mut self . memory ) ?;
561
+ let ( _, len) = value. into_slice ( & self . memory ) ?;
562
562
let align = self . type_align ( elem_ty) ?;
563
563
Ok ( ( len * elem_size, align as u64 ) )
564
564
}
0 commit comments