From 984d6967179274f55e7771d9d6ef970371e2474d Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 15 May 2017 17:05:40 +0200 Subject: [PATCH] Turns out, we never actual hash selectors --- components/selectors/gecko_like_types.rs | 8 +++--- components/selectors/parser.rs | 34 +++++++++++------------ components/style/gecko/selector_parser.rs | 4 +-- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/components/selectors/gecko_like_types.rs b/components/selectors/gecko_like_types.rs index b00d8d95667..bbb78823c50 100644 --- a/components/selectors/gecko_like_types.rs +++ b/components/selectors/gecko_like_types.rs @@ -5,7 +5,7 @@ //! These types need to have the same size and alignment as the respectively corresponding //! types in components/style/gecko/selector_parser.rs -#[derive(Eq, PartialEq, Clone, Debug, Hash)] +#[derive(Eq, PartialEq, Clone, Debug)] #[allow(dead_code)] pub enum PseudoClass { Bare, @@ -13,7 +13,7 @@ pub enum PseudoClass { MozAny(Box<[()]>), } -#[derive(Eq, PartialEq, Clone, Debug, Hash)] +#[derive(Eq, PartialEq, Clone, Debug)] pub enum PseudoElement { A, B, @@ -22,8 +22,8 @@ pub enum PseudoElement { #[derive(Eq, PartialEq, Clone, Debug)] pub struct PseudoElementSelector(PseudoElement, u64); -#[derive(Eq, PartialEq, Clone, Debug, Hash, Default)] +#[derive(Eq, PartialEq, Clone, Debug, Default)] pub struct Atom(usize); -#[derive(Eq, PartialEq, Clone, Hash)] +#[derive(Eq, PartialEq, Clone)] pub struct Impl; diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index 5dd7760adc2..82571d9bd5e 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -10,7 +10,6 @@ use std::ascii::AsciiExt; use std::borrow::{Borrow, Cow}; use std::cmp; use std::fmt::{self, Display, Debug, Write}; -use std::hash::Hash; use std::iter::Rev; use std::ops::Add; use std::slice; @@ -54,7 +53,7 @@ macro_rules! with_all_bounds { type NamespaceUrl: $($CommonBounds)* + Default + Borrow + PrecomputedHash; type NamespacePrefix: $($InSelector)* + Default; type BorrowedNamespaceUrl: ?Sized + Eq; - type BorrowedLocalName: ?Sized + Eq + Hash; + type BorrowedLocalName: ?Sized + Eq; /// non tree-structural pseudo-classes /// (see: https://drafts.csswg.org/selectors/#structural-pseudos) @@ -77,7 +76,7 @@ macro_rules! with_bounds { } with_bounds! { - [Clone + Eq + Hash] + [Clone + Eq] [From + for<'a> From<&'a str>] } @@ -113,7 +112,7 @@ pub trait Parser { } } -#[derive(PartialEq, Eq, Hash, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub struct SelectorList(pub Vec>); impl SelectorList { @@ -136,7 +135,7 @@ const NUM_ANCESTOR_HASHES: usize = 4; /// information that lives on |Selector| proper. We may want to refactor things /// and move that information elsewhere, at which point we could rename this /// to |Selector|. -#[derive(PartialEq, Eq, Hash, Clone)] +#[derive(PartialEq, Eq, Clone)] pub struct SelectorInner { /// The selector data. pub complex: ComplexSelector, @@ -176,7 +175,7 @@ impl SelectorInner { } } -#[derive(PartialEq, Eq, Hash, Clone)] +#[derive(PartialEq, Eq, Clone)] pub struct Selector { pub inner: SelectorInner, pub pseudo_element: Option, @@ -279,7 +278,7 @@ impl SelectorMethods for Component { /// We store selectors internally left-to-right (in parsing order), but the /// canonical iteration order is right-to-left (selector matching order). The /// iterators abstract over these details. -#[derive(Clone, Eq, Hash, PartialEq)] +#[derive(Clone, Eq, PartialEq)] pub struct ComplexSelector(ArcSlice>); impl ComplexSelector { @@ -405,7 +404,7 @@ impl<'a, Impl: SelectorImpl> Iterator for AncestorIter<'a, Impl> { } } -#[derive(Eq, PartialEq, Clone, Copy, Debug, Hash)] +#[derive(Eq, PartialEq, Clone, Copy, Debug)] pub enum Combinator { Child, // > Descendant, // space @@ -429,7 +428,7 @@ impl Combinator { /// optimal packing and cache performance, see [1]. /// /// [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1357973 -#[derive(Eq, PartialEq, Clone, Hash)] +#[derive(Eq, PartialEq, Clone)] pub enum Component { Combinator(Combinator), ID(Impl::Identifier), @@ -517,34 +516,33 @@ impl Component { } } -#[derive(Eq, PartialEq, Clone, Hash, Copy, Debug)] +#[derive(Eq, PartialEq, Clone, Copy, Debug)] pub enum CaseSensitivity { CaseSensitive, // Selectors spec says language-defined, but HTML says sensitive. CaseInsensitive, } -#[derive(Eq, PartialEq, Clone, Hash)] +#[derive(Eq, PartialEq, Clone)] pub struct LocalName { pub name: Impl::LocalName, pub lower_name: Impl::LocalName, } -#[derive(Eq, PartialEq, Clone, Hash)] +#[derive(Eq, PartialEq, Clone)] pub struct AttrSelector { pub name: Impl::LocalName, pub lower_name: Impl::LocalName, pub namespace: NamespaceConstraint, } -#[derive(Eq, PartialEq, Clone, Hash, Debug)] +#[derive(Eq, PartialEq, Clone, Debug)] pub enum NamespaceConstraint { Any, Specific(Namespace), } -/// FIXME(SimonSapin): should Hash only hash the URL? What is it used for? -#[derive(Eq, PartialEq, Clone, Hash)] +#[derive(Eq, PartialEq, Clone)] pub struct Namespace { pub prefix: Option, pub url: Impl::NamespaceUrl, @@ -1395,13 +1393,13 @@ pub mod tests { use std::fmt; use super::*; - #[derive(PartialEq, Clone, Debug, Hash, Eq)] + #[derive(PartialEq, Clone, Debug, Eq)] pub enum PseudoClass { Hover, Lang(String), } - #[derive(Eq, PartialEq, Clone, Debug, Hash)] + #[derive(Eq, PartialEq, Clone, Debug)] pub enum PseudoElement { Before, After, @@ -1458,7 +1456,7 @@ pub mod tests { type PseudoElementSelector = PseudoElement; } - #[derive(Default, Debug, Hash, Clone, PartialEq, Eq)] + #[derive(Default, Debug, Clone, PartialEq, Eq, Hash)] pub struct DummyAtom(String); impl fmt::Display for DummyAtom { diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index 64f135c73ae..bed3737db99 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -29,7 +29,7 @@ macro_rules! pseudo_class_name { (bare: [$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*], string: [$(($s_css:expr, $s_name:ident, $s_gecko_type:tt, $s_state:tt, $s_flags:tt),)*]) => { #[doc = "Our representation of a non tree-structural pseudo-class."] - #[derive(Clone, Debug, PartialEq, Eq, Hash)] + #[derive(Clone, Debug, PartialEq, Eq)] pub enum NonTSPseudoClass { $( #[doc = $css] @@ -185,7 +185,7 @@ impl NonTSPseudoClass { } /// The dummy struct we use to implement our selector parsing. -#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct SelectorImpl; /// Some subset of pseudo-elements in Gecko are sensitive to some state