This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
compiler/rustc_middle/src/mir/interpret Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ use crate::ty;
2828pub struct Allocation < Tag = AllocId , Extra = ( ) > {
2929 /// The actual bytes of the allocation.
3030 /// Note that the bytes of a pointer represent the offset of the pointer.
31- bytes : Vec < u8 > ,
31+ bytes : Box < [ u8 ] > ,
3232 /// Maps from byte addresses to extra data for each pointer.
3333 /// Only the first byte of a pointer is inserted into the map; i.e.,
3434 /// every entry in this map applies to `pointer_size` consecutive bytes starting
@@ -112,7 +112,7 @@ impl<Tag> Allocation<Tag> {
112112 align : Align ,
113113 mutability : Mutability ,
114114 ) -> Self {
115- let bytes = slice. into ( ) . into_owned ( ) ;
115+ let bytes = Box :: < [ u8 ] > :: from ( slice. into ( ) ) ;
116116 let size = Size :: from_bytes ( bytes. len ( ) ) ;
117117 Self {
118118 bytes,
@@ -145,9 +145,8 @@ impl<Tag> Allocation<Tag> {
145145 } ) ;
146146 InterpError :: ResourceExhaustion ( ResourceExhaustionInfo :: MemoryExhausted )
147147 } ) ?;
148- // SAFETY: This turns a Box<[MaybeUninit<u8>]> into a Vec<u8>. This is safe since the box
149- // was zero-allocated which is a valid value for u8.
150- let bytes = unsafe { bytes. assume_init ( ) . into_vec ( ) } ;
148+ // SAFETY: the box was zero-allocated, which is a valid initial value for Box<[u8]>
149+ let bytes = unsafe { bytes. assume_init ( ) } ;
151150 Ok ( Allocation {
152151 bytes,
153152 relocations : Relocations :: new ( ) ,
You can’t perform that action at this time.
0 commit comments