File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ use nalgebra::ToTypenum;
1212use rayon:: prelude:: * ;
1313use std:: cmp;
1414use std:: iter:: Sum ;
15- use std:: mem;
1615use std:: ops:: Add ;
1716use std:: ops:: AddAssign ;
1817use std:: ops:: Sub ;
@@ -259,9 +258,18 @@ where
259258 return Ok ( ( ) ) ;
260259 }
261260
261+ let atomic_partition = unsafe {
262+ // Rust does not seem to have a strict aliasing rule like C does, so the
263+ // transmute here looks safe, but we still need to ensure partition is
264+ // properly aligned for atomic types. While this should always be the
265+ // case, better safe than sorry.
266+ let ( before, partition, after) = partition. align_to_mut :: < AtomicUsize > ( ) ;
267+ assert ! ( before. is_empty( ) && after. is_empty( ) ) ;
268+ & * partition
269+ } ;
262270 let mut items: Vec < _ > = points
263271 . zip ( weights)
264- . zip ( unsafe { mem :: transmute :: < & mut [ usize ] , & [ AtomicUsize ] > ( & mut * partition ) } )
272+ . zip ( atomic_partition )
265273 . map ( |( ( point, weight) , part) | Item {
266274 point,
267275 weight,
You can’t perform that action at this time.
0 commit comments