Mark JSTraceable and its method as unsafe

This commit is contained in:
Anthony Ramine 2016-12-01 02:50:06 +01:00
parent 73b6e705b4
commit 620a67ff14
16 changed files with 191 additions and 185 deletions

View file

@ -133,7 +133,7 @@ impl<T: WeakReferenceable> PartialEq<T> for WeakRef<T> {
}
}
no_jsmanaged_fields!(WeakRef<T: WeakReferenceable>);
unsafe_no_jsmanaged_fields!(WeakRef<T: WeakReferenceable>);
impl<T: WeakReferenceable> Drop for WeakRef<T> {
fn drop(&mut self) {
@ -188,17 +188,15 @@ impl<T: WeakReferenceable> HeapSizeOf for MutableWeakRef<T> {
}
}
impl<T: WeakReferenceable> JSTraceable for MutableWeakRef<T> {
fn trace(&self, _: *mut JSTracer) {
unsafe impl<T: WeakReferenceable> JSTraceable for MutableWeakRef<T> {
unsafe fn trace(&self, _: *mut JSTracer) {
let ptr = self.cell.get();
unsafe {
let should_drop = match *ptr {
Some(ref value) => !value.is_alive(),
None => false,
};
if should_drop {
mem::drop((*ptr).take().unwrap());
}
let should_drop = match *ptr {
Some(ref value) => !value.is_alive(),
None => false,
};
if should_drop {
mem::drop((*ptr).take().unwrap());
}
}
}