servo: Merge #19294 - style: Collect more debugging info when collecting rules of detached pseudos (from emilio:debug-detached-pseudo); r=heycam

Called Option::unwrap() on a None value is not a helpful crash message.

This will hopefully help figure out what is causing bug 1418856.

Source-Repo: https://github.com/servo/servo
Source-Revision: af6c2f93b9ff91f4c3e5758d9b27173e49928bed

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 79fcf95fafaa207f4ce7bdfa08b256d388e1aa47
This commit is contained in:
Emilio Cobos Álvarez 2017-11-20 02:29:59 -06:00
parent bb68b625f9
commit 2b7e843654

View File

@ -756,11 +756,18 @@ pub trait TElement
/// element-backed pseudo-element, in which case we return the originating
/// element.
fn rule_hash_target(&self) -> Self {
let is_implemented_pseudo =
self.implemented_pseudo_element().is_some();
if is_implemented_pseudo {
self.closest_non_native_anonymous_ancestor().unwrap()
if let Some(pseudo) = self.implemented_pseudo_element() {
match self.closest_non_native_anonymous_ancestor() {
Some(e) => e,
None => {
panic!(
"Trying to collect rules for a detached pseudo-element: \
{:?} {:?}",
pseudo,
self,
)
}
}
} else {
*self
}