about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir
diff options
context:
space:
mode:
authorStrophox <strophox@gmail.com>2024-07-31 09:41:14 +0200
committerStrophox <strophox@gmail.com>2024-08-30 16:05:53 +0200
commit7fde02ea53f423ca25740e9339d8ff1db8f73052 (patch)
tree1f18dae519856ff8d3a2b24ba24889ce7adb2b9d /compiler/rustc_middle/src/mir
parent748c54848dc2964b7e133f945cabe5bc64079947 (diff)
downloadrust-7fde02ea53f423ca25740e9339d8ff1db8f73052.tar.gz
rust-7fde02ea53f423ca25740e9339d8ff1db8f73052.zip
enable Miri to pass const pointers through FFI
Co-authored-by: Ralf Jung <post@ralfj.de>
Diffstat (limited to 'compiler/rustc_middle/src/mir')
-rw-r--r--compiler/rustc_middle/src/mir/interpret/allocation.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs
index 3e101c0c635..5fb8af576ae 100644
--- a/compiler/rustc_middle/src/mir/interpret/allocation.rs
+++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs
@@ -358,10 +358,11 @@ impl Allocation {
     pub fn adjust_from_tcx<Prov: Provenance, Bytes: AllocBytes, Err>(
         &self,
         cx: &impl HasDataLayout,
+        mut alloc_bytes: impl FnMut(&[u8], Align) -> Result<Bytes, Err>,
         mut adjust_ptr: impl FnMut(Pointer<CtfeProvenance>) -> Result<Pointer<Prov>, Err>,
     ) -> Result<Allocation<Prov, (), Bytes>, Err> {
         // Copy the data.
-        let mut bytes = Bytes::from_bytes(Cow::Borrowed(&*self.bytes), self.align);
+        let mut bytes = alloc_bytes(&*self.bytes, self.align)?;
         // Adjust provenance of pointers stored in this allocation.
         let mut new_provenance = Vec::with_capacity(self.provenance.ptrs().len());
         let ptr_size = cx.data_layout().pointer_size.bytes_usize();