Auto merge of #18302 - upsuper:atom-assert, r=bholley

Harden assert for creating atom from raw pointer

One of Stylo's common assertion turns out to be from having a null Atom (see [Gecko 1385925 bug comment 7](https://bugzilla.mozilla.org/show_bug.cgi?id=1385925#c7)). It would be helpful if we can catch this kind of crash earlier via a release-assertion.

This may regress performance to some extent which I'm not sure. But we can probably have it there for diagnosis for now, and remove later.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18302)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-08-29 22:13:02 -05:00 committed by GitHub
commit 421e6d8f91

View file

@ -265,7 +265,7 @@ impl Atom {
/// called on it. /// called on it.
#[inline] #[inline]
pub unsafe fn from_addrefed(ptr: *mut nsIAtom) -> Self { pub unsafe fn from_addrefed(ptr: *mut nsIAtom) -> Self {
debug_assert!(!ptr.is_null()); assert!(!ptr.is_null());
unsafe { unsafe {
Atom(WeakAtom::new(ptr)) Atom(WeakAtom::new(ptr))
} }
@ -378,7 +378,7 @@ impl From<String> for Atom {
impl From<*mut nsIAtom> for Atom { impl From<*mut nsIAtom> for Atom {
#[inline] #[inline]
fn from(ptr: *mut nsIAtom) -> Atom { fn from(ptr: *mut nsIAtom) -> Atom {
debug_assert!(!ptr.is_null()); assert!(!ptr.is_null());
unsafe { unsafe {
let ret = Atom(WeakAtom::new(ptr)); let ret = Atom(WeakAtom::new(ptr));
if !ret.is_static() { if !ret.is_static() {