@@ -276,7 +276,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
276276 kind : MemoryKind < M :: MemoryKind > ,
277277 ) -> InterpResult < ' tcx > {
278278 let ( alloc_id, offset, tag) = self . ptr_get_alloc_id ( ptr) ?;
279- trace ! ( "deallocating: {}" , alloc_id ) ;
279+ trace ! ( "deallocating: {alloc_id:?}" ) ;
280280
281281 if offset. bytes ( ) != 0 {
282282 throw_ub_format ! (
@@ -289,10 +289,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
289289 // Deallocating global memory -- always an error
290290 return Err ( match self . tcx . get_global_alloc ( alloc_id) {
291291 Some ( GlobalAlloc :: Function ( ..) ) => {
292- err_ub_format ! ( "deallocating {}, which is a function" , alloc_id )
292+ err_ub_format ! ( "deallocating {alloc_id:? }, which is a function" )
293293 }
294294 Some ( GlobalAlloc :: Static ( ..) | GlobalAlloc :: Memory ( ..) ) => {
295- err_ub_format ! ( "deallocating {}, which is static memory" , alloc_id )
295+ err_ub_format ! ( "deallocating {alloc_id:? }, which is static memory" )
296296 }
297297 None => err_ub ! ( PointerUseAfterFree ( alloc_id) ) ,
298298 }
@@ -302,21 +302,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
302302 debug ! ( ?alloc) ;
303303
304304 if alloc. mutability == Mutability :: Not {
305- throw_ub_format ! ( "deallocating immutable allocation {}" , alloc_id ) ;
305+ throw_ub_format ! ( "deallocating immutable allocation {alloc_id:?}" ) ;
306306 }
307307 if alloc_kind != kind {
308308 throw_ub_format ! (
309- "deallocating {}, which is {} memory, using {} deallocation operation" ,
310- alloc_id,
311- alloc_kind,
312- kind
309+ "deallocating {alloc_id:?}, which is {alloc_kind} memory, using {kind} deallocation operation"
313310 ) ;
314311 }
315312 if let Some ( ( size, align) ) = old_size_and_align {
316313 if size != alloc. size ( ) || align != alloc. align {
317314 throw_ub_format ! (
318- "incorrect layout on deallocation: {} has size {} and alignment {}, but gave size {} and alignment {}" ,
319- alloc_id,
315+ "incorrect layout on deallocation: {alloc_id:?} has size {} and alignment {}, but gave size {} and alignment {}" ,
320316 alloc. size( ) . bytes( ) ,
321317 alloc. align. bytes( ) ,
322318 size. bytes( ) ,
@@ -815,7 +811,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> std::fmt::Debug for DumpAllocs<'a,
815811 continue ;
816812 }
817813
818- write ! ( fmt, "{}" , id ) ?;
814+ write ! ( fmt, "{id:?}" ) ?;
819815 match self . ecx . memory . alloc_map . get ( id) {
820816 Some ( & ( kind, ref alloc) ) => {
821817 // normal alloc
@@ -859,25 +855,21 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> std::fmt::Debug for DumpAllocs<'a,
859855
860856/// Reading and writing.
861857impl < ' tcx , ' a , Tag : Provenance , Extra > AllocRefMut < ' a , ' tcx , Tag , Extra > {
858+ /// `range` is relative to this allocation reference, not the base of the allocation.
862859 pub fn write_scalar (
863860 & mut self ,
864861 range : AllocRange ,
865862 val : ScalarMaybeUninit < Tag > ,
866863 ) -> InterpResult < ' tcx > {
867864 let range = self . range . subrange ( range) ;
868- debug ! (
869- "write_scalar in {} at {:#x}, size {}: {:?}" ,
870- self . alloc_id,
871- range. start. bytes( ) ,
872- range. size. bytes( ) ,
873- val
874- ) ;
865+ debug ! ( "write_scalar at {:?}{range:?}: {val:?}" , self . alloc_id) ;
875866 Ok ( self
876867 . alloc
877868 . write_scalar ( & self . tcx , range, val)
878869 . map_err ( |e| e. to_interp_error ( self . alloc_id ) ) ?)
879870 }
880871
872+ /// `offset` is relative to this allocation reference, not the base of the allocation.
881873 pub fn write_ptr_sized (
882874 & mut self ,
883875 offset : Size ,
@@ -896,6 +888,7 @@ impl<'tcx, 'a, Tag: Provenance, Extra> AllocRefMut<'a, 'tcx, Tag, Extra> {
896888}
897889
898890impl < ' tcx , ' a , Tag : Provenance , Extra > AllocRef < ' a , ' tcx , Tag , Extra > {
891+ /// `range` is relative to this allocation reference, not the base of the allocation.
899892 pub fn read_scalar (
900893 & self ,
901894 range : AllocRange ,
@@ -906,31 +899,24 @@ impl<'tcx, 'a, Tag: Provenance, Extra> AllocRef<'a, 'tcx, Tag, Extra> {
906899 . alloc
907900 . read_scalar ( & self . tcx , range, read_provenance)
908901 . map_err ( |e| e. to_interp_error ( self . alloc_id ) ) ?;
909- debug ! (
910- "read_scalar in {} at {:#x}, size {}: {:?}" ,
911- self . alloc_id,
912- range. start. bytes( ) ,
913- range. size. bytes( ) ,
914- res
915- ) ;
902+ debug ! ( "read_scalar at {:?}{range:?}: {res:?}" , self . alloc_id) ;
916903 Ok ( res)
917904 }
918905
919- pub fn read_integer (
920- & self ,
921- offset : Size ,
922- size : Size ,
923- ) -> InterpResult < ' tcx , ScalarMaybeUninit < Tag > > {
924- self . read_scalar ( alloc_range ( offset, size) , /*read_provenance*/ false )
906+ /// `range` is relative to this allocation reference, not the base of the allocation.
907+ pub fn read_integer ( & self , range : AllocRange ) -> InterpResult < ' tcx , ScalarMaybeUninit < Tag > > {
908+ self . read_scalar ( range, /*read_provenance*/ false )
925909 }
926910
911+ /// `offset` is relative to this allocation reference, not the base of the allocation.
927912 pub fn read_pointer ( & self , offset : Size ) -> InterpResult < ' tcx , ScalarMaybeUninit < Tag > > {
928913 self . read_scalar (
929914 alloc_range ( offset, self . tcx . data_layout ( ) . pointer_size ) ,
930915 /*read_provenance*/ true ,
931916 )
932917 }
933918
919+ /// `range` is relative to this allocation reference, not the base of the allocation.
934920 pub fn check_bytes (
935921 & self ,
936922 range : AllocRange ,
0 commit comments