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 4141[submodule "library/backtrace "]
4242 path = library/backtrace
4343 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> {
218218
219219 let mut bytes = vec_align. into_boxed_slice ( ) ;
220220 assert ! ( bytes. as_ptr( ) as u64 % align. bytes( ) == 0 ) ;
221- bytes[ ..slice . len ( ) ] . copy_from_slice ( & slice) ;
221+ bytes. copy_from_slice ( & slice) ;
222222
223223 Self {
224224 bytes,
@@ -285,10 +285,11 @@ impl Allocation {
285285 // Compute new pointer provenance, which also adjusts the bytes.
286286 // Realign the pointer
287287 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+ } ;
292293 assert ! ( vec_align. as_ptr( ) as usize % align_usize == 0 ) ;
293294
294295 vec_align[ ..self . bytes . len ( ) ] . copy_from_slice ( & self . bytes ) ;
You can’t perform that action at this time.
0 commit comments