Bug 1444151 - Part 2: Make Rust's RefPtr::forget safe, r=froydnj
authorNika Layzell <nika@thelayzells.com>
Thu, 08 Mar 2018 12:27:12 -0500
changeset 412767 06e75a3b8d8e8562a1126bbc96758e402170dc94
parent 412766 beff5418f8e54241c11f24ceba2d67a7e6490124
child 412768 a0c94bfa5a40a7a8106ba0d8320c40c58fc6449d
push id33818
push userapavel@mozilla.com
push dateWed, 11 Apr 2018 14:36:40 +0000
treeherdermozilla-central@cfe6399e142c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1444151
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1444151 - Part 2: Make Rust's RefPtr::forget safe, r=froydnj
xpcom/rust/xpcom/src/refptr.rs
--- a/xpcom/rust/xpcom/src/refptr.rs
+++ b/xpcom/rust/xpcom/src/refptr.rs
@@ -75,18 +75,18 @@ impl <T: RefCounted + 'static> RefPtr<T>
         Some(RefPtr {
             _ptr: &*p,
             _marker: PhantomData,
         })
     }
 
     /// Write this RefPtr's value into an outparameter.
     #[inline]
-    pub unsafe fn forget(self, into: &mut *const T) {
-        *into = &*self as *const T;
+    pub fn forget(self, into: &mut *const T) {
+        *into = &*self;
         mem::forget(self);
     }
 }
 
 impl <T: RefCounted + 'static> Deref for RefPtr<T> {
     type Target = T;
     #[inline]
     fn deref(&self) -> &T {