diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 0f2a11cc1db..837d709e882 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -933,12 +933,26 @@ trait RcBoxPtr { impl RcBoxPtr for Rc { #[inline(always)] - fn inner(&self) -> &RcBox { unsafe { &(**self._ptr) } } + fn inner(&self) -> &RcBox { + 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 RcBoxPtr for Weak { #[inline(always)] - fn inner(&self) -> &RcBox { unsafe { &(**self._ptr) } } + fn inner(&self) -> &RcBox { + 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)]