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 ;
@@ -254,9 +253,18 @@ where
254253 } ) ;
255254 }
256255
256+ let atomic_partition = unsafe {
257+ // Rust does not seem to have a strict aliasing rule like C does, so the
258+ // transmute here looks safe, but we still need to ensure partition is
259+ // properly aligned for atomic types. While this should always be the
260+ // case, better safe than sorry.
261+ let ( before, partition, after) = partition. align_to_mut :: < AtomicUsize > ( ) ;
262+ assert ! ( before. is_empty( ) && after. is_empty( ) ) ;
263+ & * partition
264+ } ;
257265 let mut items: Vec < _ > = points
258266 . zip ( weights)
259- . zip ( unsafe { mem :: transmute :: < & mut [ usize ] , & [ AtomicUsize ] > ( & mut * partition ) } )
267+ . zip ( atomic_partition )
260268 . map ( |( ( point, weight) , part) | Item {
261269 point,
262270 weight,
You can’t perform that action at this time.
0 commit comments