11use std:: alloc;
22use std:: alloc:: Layout ;
3- use std:: slice;
43use std:: borrow:: Cow ;
4+ use std:: slice;
55
6- use rustc_target:: abi:: { Align , Size } ;
76use rustc_middle:: mir:: interpret:: AllocBytes ;
7+ use rustc_target:: abi:: { Align , Size } ;
88
9- /// The bytes of a Miri allocation, allocated using the size and alignment requested
10- /// by the interpreted program.
11- /// This is necessary to interface with native code that exchanges pointers with the
12- /// interpreted program.
9+ /// Allocation bytes that explicitly handle the layout of the data they're storing.
10+ /// This is necessary to interface with native code that accesses the program store in Miri.
1311#[ derive( Debug ) ]
14- #[ derive( PartialEq , Eq , Hash ) ] // TODO Necessary?
1512pub struct MiriAllocBytes {
1613 /// Stored layout information about the allocation.
1714 layout : alloc:: Layout ,
@@ -63,7 +60,11 @@ impl MiriAllocBytes {
6360 /// specifically given an allocation function `alloc_fn`.
6461 /// `alloc_fn` is only used if `size != 0`.
6562 /// Returns `Err(layout)` if the allocation function returns a `ptr` that is `ptr.is_null()`.
66- fn alloc_with ( size : usize , align : usize , alloc_fn : impl FnOnce ( Layout ) -> * mut u8 ) -> Result < MiriAllocBytes , Layout > {
63+ fn alloc_with (
64+ size : usize ,
65+ align : usize ,
66+ alloc_fn : impl FnOnce ( Layout ) -> * mut u8 ,
67+ ) -> Result < MiriAllocBytes , Layout > {
6768 let layout = Layout :: from_size_align ( size, align) . unwrap ( ) ;
6869 let ptr = if size == 0 {
6970 align as * mut u8 // std::ptr::without_provenance_mut(align) : "use of unstable library feature 'strict_provenance'"
@@ -106,4 +107,4 @@ impl AllocBytes for MiriAllocBytes {
106107 fn as_mut_ptr ( & mut self ) -> * mut u8 {
107108 self . ptr
108109 }
109- }
110+ }
0 commit comments