mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-04 18:40:57 +03:00
Add assumptions that the pointer is non-null
This commit is contained in:
+16
-2
@@ -933,12 +933,26 @@ fn weak(&self) -> uint { self.inner().weak.get() }
|
||||
|
||||
impl<T> RcBoxPtr<T> for Rc<T> {
|
||||
#[inline(always)]
|
||||
fn inner(&self) -> &RcBox<T> { unsafe { &(**self._ptr) } }
|
||||
fn inner(&self) -> &RcBox<T> {
|
||||
unsafe {
|
||||
// Safe to assume this here, as if it weren't true, we'd be breaking
|
||||
// the contract anyway
|
||||
assume(!self._ptr.is_null());
|
||||
&(**self._ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> RcBoxPtr<T> for Weak<T> {
|
||||
#[inline(always)]
|
||||
fn inner(&self) -> &RcBox<T> { unsafe { &(**self._ptr) } }
|
||||
fn inner(&self) -> &RcBox<T> {
|
||||
unsafe {
|
||||
// Safe to assume this here, as if it weren't true, we'd be breaking
|
||||
// the contract anyway
|
||||
assume(!self._ptr.is_null());
|
||||
&(**self._ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user