File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
compiler/rustc_middle/src/mir/interpret Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -270,6 +270,23 @@ impl AllocRange {
270270
271271// The constructors are all without extra; the extra gets added by a machine hook later.
272272impl < Prov : Provenance , Bytes : AllocBytes > Allocation < Prov , ( ) , Bytes > {
273+ /// Creates an allocation from an existing `Bytes` value - this is needed for miri FFI support
274+ pub fn from_raw_bytes < ' a > (
275+ bytes : Bytes ,
276+ align : Align ,
277+ mutability : Mutability ,
278+ ) -> Self {
279+ let size = Size :: from_bytes ( bytes. len ( ) ) ;
280+ Self {
281+ bytes,
282+ provenance : ProvenanceMap :: new ( ) ,
283+ init_mask : InitMask :: new ( size, true ) ,
284+ align,
285+ mutability,
286+ extra : ( ) ,
287+ }
288+ }
289+
273290 /// Creates an allocation initialized by the given bytes
274291 pub fn from_bytes < ' a > (
275292 slice : impl Into < Cow < ' a , [ u8 ] > > ,
You can’t perform that action at this time.
0 commit comments