File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -63,17 +63,17 @@ impl<T: Copy> List<T> {
6363
6464 let ( layout, _offset) =
6565 Layout :: new :: < usize > ( ) . extend ( Layout :: for_value :: < [ T ] > ( slice) ) . unwrap ( ) ;
66- let mem = arena. dropless . alloc_raw ( layout) ;
66+ let mem = arena. dropless . alloc_raw ( layout) as * mut List < T > ;
6767 unsafe {
68- let result = & mut * ( mem as * mut List < T > ) ;
6968 // Write the length
70- result . len = slice. len ( ) ;
69+ ptr :: addr_of_mut! ( ( * mem ) . len) . write ( slice. len ( ) ) ;
7170
7271 // Write the elements
73- let arena_slice = slice:: from_raw_parts_mut ( result. data . as_mut_ptr ( ) , result. len ) ;
74- arena_slice. copy_from_slice ( slice) ;
72+ ptr:: addr_of_mut!( ( * mem) . data)
73+ . cast :: < T > ( )
74+ . copy_from_nonoverlapping ( slice. as_ptr ( ) , slice. len ( ) ) ;
7575
76- result
76+ & mut * mem
7777 }
7878 }
7979
You can’t perform that action at this time.
0 commit comments