servo: Assert that self.has_aux() in rcu before returning aux
authorPatrick Walton <pcwalton@mimiga.net>
Thu, 10 May 2012 15:15:19 -0700
changeset 361565 497eec33438ba621d64d4cb4c357ba0f13a15536
parent 361564 db2b671e7af01e26acaaaaedcee2e3613a36104b
child 361566 689b54b0444ce6fa71fde9ace60cd4581c43b0fe
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
servo: Assert that self.has_aux() in rcu before returning aux Source-Repo: https://github.com/servo/servo Source-Revision: 4938e1733ce0854dd5abd5c960c88f643d808e4d
servo/src/servo/dom/rcu.rs
--- a/servo/src/servo/dom/rcu.rs
+++ b/servo/src/servo/dom/rcu.rs
@@ -51,17 +51,17 @@ impl reader_methods<T:send,A> for handle
         self.rd_aux().is_not_null()
     }
 
     fn set_aux(p: @A) unsafe {
         (**self).rd_aux = ptr::addr_of(*p);
     }
 
     fn aux<U>(f: fn(A) -> U) -> U unsafe {
-        // warning: do not use if has_aux() is false!
+        assert self.has_aux();
         f(*self.rd_aux())
     }
 }
 
 impl private_methods<T:send,A> for scope<T,A> {
     fn clone(v: *T) -> *T unsafe {
         let n: *mut T =
             unsafe::reinterpret_cast(
@@ -235,9 +235,9 @@ mod test {
             }
             s.reader_joined();
         }
 
         assert henrietta.rd(read_characteristic) == iter1 * iter2;
         assert ferdinand.rd(read_characteristic) == iter1 * iter2;
     }
 
-}
\ No newline at end of file
+}