Skip to content

Commit 4f744e6

Browse files
committed
Work around an ICE due to autoderef.
This is a workaround for rust-lang/rust#17810.
1 parent 862d476 commit 4f744e6

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/partitioning/dbvt.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ DBVT<B, BV> {
4444
pub fn remove(&mut self, leaf: &mut Rc<RefCell<DBVTLeaf<B, BV>>>) {
4545
let self_tree = self.tree.take().unwrap();
4646

47-
let mut bleaf = leaf.borrow_mut();
47+
let mut bleaf = (*leaf).borrow_mut();
4848
self.tree = bleaf.unlink(&mut self.cache, self_tree);
4949
self.len = self.len - 1;
5050
}
@@ -267,9 +267,7 @@ impl<B: 'static, BV: Translation<Vect> + 'static> DBVTLeaf<B, BV> {
267267
match other {
268268
Internal(ref mut i) => i.parent = pp,
269269
Leaf(ref mut l) => {
270-
// FIXME: if deref_mut is not called, the type inference seems to be
271-
// buggy
272-
l.borrow_mut().deref_mut().parent =
270+
(**l).borrow_mut().parent =
273271
if is_p_right_to_pp { RightChildOf(pp) } else { LeftChildOf(pp) }
274272
},
275273
Invalid => unreachable!()
@@ -295,9 +293,7 @@ impl<B: 'static, BV: Translation<Vect> + 'static> DBVTLeaf<B, BV> {
295293
// the root changes to the other child
296294
match other {
297295
Internal(ref mut i) => i.parent = ptr::null_mut(),
298-
// FIXME: if deref_mut is not called, the type inference seems to be
299-
// buggy
300-
Leaf(ref l) => l.borrow_mut().deref_mut().parent = Detached,
296+
Leaf(ref l) => (**l).borrow_mut().parent = Detached,
301297
Invalid => unreachable!()
302298
}
303299

@@ -367,7 +363,7 @@ impl<BV: 'static + BoundingVolume + Translation<Vect> + Clone, B: 'static + Clon
367363
to_insert: Rc<RefCell<DBVTLeaf<B, BV>>>)
368364
-> Box<DBVTInternal<B, BV>> {
369365

370-
let mut bto_insert = to_insert.borrow_mut();
366+
let mut bto_insert = (*to_insert).borrow_mut();
371367
let pto_insert = bto_insert.deref_mut();
372368

373369
match self {
@@ -415,7 +411,7 @@ impl<BV: 'static + BoundingVolume + Translation<Vect> + Clone, B: 'static + Clon
415411
parent = &mut **ci as *mut DBVTInternal<B, BV>;
416412
},
417413
Leaf(ref l) => {
418-
let mut bl = l.borrow_mut();
414+
let mut bl = (**l).borrow_mut();
419415
let pl = bl.deref_mut();
420416
let mut internal = cache.alloc(DBVTInternal::new(
421417
pl.bounding_volume.merged(&pto_insert.bounding_volume),
@@ -444,7 +440,7 @@ impl<BV: 'static + BoundingVolume + Translation<Vect> + Clone, B: 'static + Clon
444440
},
445441
Leaf(l) => {
446442
let cl = l.clone();
447-
let mut bl = cl.borrow_mut();
443+
let mut bl = (*cl).borrow_mut();
448444
let pl = bl.deref_mut();
449445

450446
// create the root

0 commit comments

Comments
 (0)