Move fn Disjoint{Immut,Mut}Guard::new
disjoint panic checks to before reference is materialized to avoid UB
#1355
Labels
From #1354, @workingjubilee pointed out that we need to put the panic checks in
DisjointMut
before doing the what would be unsound operation:This should be possible if we rework the
fn index{,_mut}
methods andfn Disjoint{Immut,Mut}Guard::new
constructor to do the disjoint check before doing theunsafe { &mut *... }
orunsafe { &*... }
on the result ofindex.get_mut
, which is what creates the references and is what is UB if we do it when the ranges are not actually disjoint.The text was updated successfully, but these errors were encountered: