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;
28
28
pub struct Allocation < Tag = AllocId , Extra = ( ) > {
29
29
/// The actual bytes of the allocation.
30
30
/// Note that the bytes of a pointer represent the offset of the pointer.
31
- bytes : Vec < u8 > ,
31
+ bytes : Box < [ u8 ] > ,
32
32
/// Maps from byte addresses to extra data for each pointer.
33
33
/// Only the first byte of a pointer is inserted into the map; i.e.,
34
34
/// every entry in this map applies to `pointer_size` consecutive bytes starting
@@ -112,7 +112,7 @@ impl<Tag> Allocation<Tag> {
112
112
align : Align ,
113
113
mutability : Mutability ,
114
114
) -> Self {
115
- let bytes = slice. into ( ) . into_owned ( ) ;
115
+ let bytes = Box :: < [ u8 ] > :: from ( slice. into ( ) ) ;
116
116
let size = Size :: from_bytes ( bytes. len ( ) ) ;
117
117
Self {
118
118
bytes,
@@ -145,9 +145,8 @@ impl<Tag> Allocation<Tag> {
145
145
} ) ;
146
146
InterpError :: ResourceExhaustion ( ResourceExhaustionInfo :: MemoryExhausted )
147
147
} ) ?;
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 ( ) } ;
151
150
Ok ( Allocation {
152
151
bytes,
153
152
relocations : Relocations :: new ( ) ,
You can’t perform that action at this time.
0 commit comments