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.
This commit is contained in:
Emilio Cobos Álvarez 2017-11-20 07:41:05 +01:00
parent 63bd783c55
commit 143341a061
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

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
}