@@ -208,7 +208,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
208208 let new_ptr = self . allocate ( new_mem_pos, kind) ;
209209 let old_size = match old_mem_pos {
210210 Some ( old_mem_pos) => old_mem_pos. size ,
211- None => self . get_raw ( ptr. alloc_id ) ?. size ,
211+ None => self . get_raw ( ptr. alloc_id ) ?. mem_pos . size ,
212212 } ;
213213 self . copy (
214214 ptr,
@@ -268,21 +268,23 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
268268 format!( "{:?}" , kind) ,
269269 ) )
270270 }
271+
272+ let bytes_mem_pos = alloc. mem_pos ;
273+
271274 if let Some ( mem_pos) = old_mem_pos {
272- if mem_pos != MemoryPosition :: new ( alloc. size , alloc. align ) {
273- let got_mem_pos = MemoryPosition :: new ( alloc. size , alloc. align ) ;
274- throw_unsup ! ( IncorrectAllocationInformation ( mem_pos, got_mem_pos) )
275+ if mem_pos != bytes_mem_pos {
276+ throw_unsup ! ( IncorrectAllocationInformation ( mem_pos, bytes_mem_pos) )
275277 }
276278 }
277279
278280 // Let the machine take some extra action
279- let size = alloc. size ;
281+ let size = alloc. mem_pos . size ;
280282 AllocationExtra :: memory_deallocated ( & mut alloc, ptr, size) ?;
281283
282284 // Don't forget to remember size and align of this now-dead allocation
283285 let old = self . dead_alloc_map . insert (
284286 ptr. alloc_id ,
285- ( alloc. size , alloc. align )
287+ ( alloc. mem_pos . size , alloc. mem_pos . align )
286288 ) ;
287289 if old. is_some ( ) {
288290 bug ! ( "Nothing can be deallocated twice" ) ;
@@ -561,7 +563,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
561563 // a) cause cycles in case `id` refers to a static
562564 // b) duplicate a static's allocation in miri
563565 if let Some ( ( _, alloc) ) = self . alloc_map . get ( id) {
564- return Ok ( ( alloc. size , alloc. align ) ) ;
566+ return Ok ( ( alloc. mem_pos . size , alloc. mem_pos . align ) ) ;
565567 }
566568
567569 // # Function pointers
@@ -589,7 +591,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
589591 Some ( GlobalAlloc :: Memory ( alloc) ) =>
590592 // Need to duplicate the logic here, because the global allocations have
591593 // different associated types than the interpreter-local ones.
592- Ok ( ( alloc. size , alloc. align ) ) ,
594+ Ok ( ( alloc. mem_pos . size , alloc. mem_pos . align ) ) ,
593595 Some ( GlobalAlloc :: Function ( _) ) =>
594596 bug ! ( "We already checked function pointers above" ) ,
595597 // The rest must be dead.
@@ -651,7 +653,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
651653 let prefix_len = msg. len ( ) ;
652654 let mut relocations = vec ! [ ] ;
653655
654- for i in 0 ..alloc. size . bytes ( ) {
656+ for i in 0 ..alloc. mem_pos . size . bytes ( ) {
655657 let i = Size :: from_bytes ( i) ;
656658 if let Some ( & ( _, target_id) ) = alloc. relocations ( ) . get ( & i) {
657659 if allocs_seen. insert ( target_id) {
@@ -675,8 +677,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
675677 trace ! (
676678 "{}({} bytes, alignment {}){}" ,
677679 msg,
678- alloc. size. bytes( ) ,
679- alloc. align. bytes( ) ,
680+ alloc. mem_pos . size. bytes( ) ,
681+ alloc. mem_pos . align. bytes( ) ,
680682 extra
681683 ) ;
682684
0 commit comments