From 143341a061b0d2b20aaac147dfa447baa1a93e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 20 Nov 2017 07:41:05 +0100 Subject: [PATCH] style: Collect more debugging info when collecting rules of detached pseudos. Called Option::unwrap() on a None value is not a helpful crash message. This will hopefully help figure out what is causing bug 1418856. --- components/style/dom.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/components/style/dom.rs b/components/style/dom.rs index b1a12307311..1916e8db730 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -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 }