stylo: Add debug docs assertion in Atom::from_static()

This commit is contained in:
Emilio Cobos Álvarez 2016-08-15 23:02:24 -07:00
parent 2b3c684b37
commit 09cc240d4c
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -171,9 +171,18 @@ impl Atom {
mem::forget(atom); mem::forget(atom);
} }
/// Creates an atom from an static atom pointer without checking in release
/// builds.
///
/// Right now it's only used by the atom macro, and ideally it should keep
/// that way, now we have sugar for is_static, creating atoms using
/// Atom::from should involve almost no overhead.
#[inline] #[inline]
unsafe fn from_static(ptr: *mut nsIAtom) -> Self { unsafe fn from_static(ptr: *mut nsIAtom) -> Self {
Atom(ptr as *mut WeakAtom) let atom = Atom(ptr as *mut WeakAtom);
debug_assert!(atom.is_static(),
"Called from_static for a non-static atom!");
atom
} }
} }