mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make JSTraceable for DomRefCell<T> panic if cell is mutably borrowed (see #19871)
This commit is contained in:
parent
c9ba16f9fb
commit
31a14082eb
2 changed files with 1 additions and 13 deletions
|
@ -29,18 +29,6 @@ impl<T> DomRefCell<T> {
|
|||
&*self.value.as_ptr()
|
||||
}
|
||||
|
||||
/// Borrow the contents for the purpose of GC tracing.
|
||||
///
|
||||
/// This succeeds even if the object is mutably borrowed,
|
||||
/// so you have to be careful in trace code!
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn borrow_for_gc_trace(&self) -> &T {
|
||||
// FIXME: IN_GC isn't reliable enough - doesn't catch minor GCs
|
||||
// https://github.com/servo/servo/issues/6389
|
||||
// debug_assert!(thread_state::get().contains(SCRIPT | IN_GC));
|
||||
&*self.value.as_ptr()
|
||||
}
|
||||
|
||||
/// Borrow the contents for the purpose of script deallocation.
|
||||
///
|
||||
#[allow(unsafe_code)]
|
||||
|
|
|
@ -206,7 +206,7 @@ unsafe impl<T: JSTraceable> JSTraceable for UnsafeCell<T> {
|
|||
|
||||
unsafe impl<T: JSTraceable> JSTraceable for DomRefCell<T> {
|
||||
unsafe fn trace(&self, trc: *mut JSTracer) {
|
||||
(*self).borrow_for_gc_trace().trace(trc)
|
||||
(*self).borrow().trace(trc)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue