File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed
compiler/rustc_middle/src/mir/interpret Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change 41
41
[submodule "library/backtrace "]
42
42
path = library/backtrace
43
43
url = https://github.com/rust-lang/backtrace-rs.git
44
- [submodule "src/tools/miri/ "]
45
- url = https://github.com/emarteca/miri
46
- branch = matt-alloc-hacks
Original file line number Diff line number Diff line change @@ -218,7 +218,7 @@ impl<Prov> Allocation<Prov> {
218
218
219
219
let mut bytes = vec_align. into_boxed_slice ( ) ;
220
220
assert ! ( bytes. as_ptr( ) as u64 % align. bytes( ) == 0 ) ;
221
- bytes[ ..slice . len ( ) ] . copy_from_slice ( & slice) ;
221
+ bytes. copy_from_slice ( & slice) ;
222
222
223
223
Self {
224
224
bytes,
@@ -285,10 +285,11 @@ impl Allocation {
285
285
// Compute new pointer provenance, which also adjusts the bytes.
286
286
// Realign the pointer
287
287
let align_usize: usize = self . align . bytes ( ) . try_into ( ) . unwrap ( ) ;
288
- let count_align = ( ( self . bytes . len ( ) / align_usize) + 1 ) * align_usize;
289
-
290
- let mut vec_align: Vec < u8 > = Vec :: with_capacity ( count_align) ;
291
- vec_align. resize ( count_align, 0 ) ;
288
+ let layout = std:: alloc:: Layout :: from_size_align ( self . bytes . len ( ) , align_usize) . unwrap ( ) ;
289
+ let mut vec_align = unsafe {
290
+ let buf = std:: alloc:: alloc ( layout) ;
291
+ Vec :: from_raw_parts ( buf as * mut u8 , self . bytes . len ( ) , self . bytes . len ( ) )
292
+ } ;
292
293
assert ! ( vec_align. as_ptr( ) as usize % align_usize == 0 ) ;
293
294
294
295
vec_align[ ..self . bytes . len ( ) ] . copy_from_slice ( & self . bytes ) ;
You can’t perform that action at this time.
0 commit comments