@@ -116,36 +116,33 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
116
116
. map( |( size, _) | size)
117
117
. unwrap_or_else( || place. layout. size)
118
118
) ;
119
- assert ! ( size . bytes ( ) > 0 ) ;
119
+ let place = this . normalize_mplace_ptr ( place ) ? ;
120
120
// Store how far we proceeded into the place so far. Everything to the left of
121
121
// this offset has already been handled, in the sense that the frozen parts
122
122
// have had `action` called on them.
123
- let mut end_ptr = place. ptr ;
123
+ let mut end_ptr = place. ptr . assert_ptr ( ) ;
124
124
// Called when we detected an `UnsafeCell` at the given offset and size.
125
125
// Calls `action` and advances `end_ptr`.
126
126
let mut unsafe_cell_action = |unsafe_cell_ptr : Scalar < Tag > , unsafe_cell_size : Size | {
127
- if unsafe_cell_size != Size :: ZERO {
128
- debug_assert_eq ! ( unsafe_cell_ptr. to_ptr( ) . unwrap( ) . alloc_id,
129
- end_ptr. to_ptr( ) . unwrap( ) . alloc_id) ;
130
- debug_assert_eq ! ( unsafe_cell_ptr. to_ptr( ) . unwrap( ) . tag,
131
- end_ptr. to_ptr( ) . unwrap( ) . tag) ;
132
- }
127
+ let unsafe_cell_ptr = unsafe_cell_ptr. assert_ptr ( ) ;
128
+ debug_assert_eq ! ( unsafe_cell_ptr. alloc_id, end_ptr. alloc_id) ;
129
+ debug_assert_eq ! ( unsafe_cell_ptr. tag, end_ptr. tag) ;
133
130
// We assume that we are given the fields in increasing offset order,
134
131
// and nothing else changes.
135
- let unsafe_cell_offset = unsafe_cell_ptr. get_ptr_offset ( this ) ;
136
- let end_offset = end_ptr. get_ptr_offset ( this ) ;
132
+ let unsafe_cell_offset = unsafe_cell_ptr. offset ;
133
+ let end_offset = end_ptr. offset ;
137
134
assert ! ( unsafe_cell_offset >= end_offset) ;
138
135
let frozen_size = unsafe_cell_offset - end_offset;
139
136
// Everything between the end_ptr and this `UnsafeCell` is frozen.
140
137
if frozen_size != Size :: ZERO {
141
- action ( end_ptr. to_ptr ( ) ? , frozen_size, /*frozen*/ true ) ?;
138
+ action ( end_ptr, frozen_size, /*frozen*/ true ) ?;
142
139
}
143
140
// This `UnsafeCell` is NOT frozen.
144
141
if unsafe_cell_size != Size :: ZERO {
145
- action ( unsafe_cell_ptr. to_ptr ( ) ? , unsafe_cell_size, /*frozen*/ false ) ?;
142
+ action ( unsafe_cell_ptr, unsafe_cell_size, /*frozen*/ false ) ?;
146
143
}
147
144
// Update end end_ptr.
148
- end_ptr = unsafe_cell_ptr. ptr_wrapping_offset ( unsafe_cell_size, this) ;
145
+ end_ptr = unsafe_cell_ptr. wrapping_offset ( unsafe_cell_size, this) ;
149
146
// Done
150
147
Ok ( ( ) )
151
148
} ;
@@ -234,7 +231,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
234
231
layout:: FieldPlacement :: Arbitrary { .. } => {
235
232
// Gather the subplaces and sort them before visiting.
236
233
let mut places = fields. collect :: < InterpResult < ' tcx , Vec < MPlaceTy < ' tcx , Tag > > > > ( ) ?;
237
- places. sort_by_key ( |place| place. ptr . get_ptr_offset ( self . ecx ( ) ) ) ;
234
+ places. sort_by_key ( |place| place. ptr . assert_ptr ( ) . offset ) ;
238
235
self . walk_aggregate ( place, places. into_iter ( ) . map ( Ok ) )
239
236
}
240
237
layout:: FieldPlacement :: Union { .. } => {
0 commit comments