Skip to content

Commit

Permalink
Remove duplicate style rules
Browse files Browse the repository at this point in the history
Closes #456
  • Loading branch information
devongovett committed Apr 9, 2023
1 parent c5fcb63 commit aa083a7
Show file tree
Hide file tree
Showing 11 changed files with 480 additions and 27 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -56,6 +56,7 @@ data-encoding = "2.3.2"
lazy_static = "1.4.0"
const-str = "0.3.1"
pathdiff = "0.2.1"
ahash = "0.7.6"
# CLI deps
atty = { version = "0.2", optional = true }
clap = { version = "3.0.6", features = ["derive"], optional = true }
Expand Down
12 changes: 6 additions & 6 deletions selectors/attr.rs
Expand Up @@ -6,7 +6,7 @@ use crate::parser::SelectorImpl;
use cssparser::ToCss;
use std::fmt;

#[derive(Clone, Eq, PartialEq)]
#[derive(Clone, Eq, PartialEq, Hash)]
pub struct AttrSelectorWithOptionalNamespace<'i, Impl: SelectorImpl<'i>> {
pub namespace: Option<NamespaceConstraint<(Impl::NamespacePrefix, Impl::NamespaceUrl)>>,
pub local_name: Impl::LocalName,
Expand All @@ -24,7 +24,7 @@ impl<'i, Impl: SelectorImpl<'i>> AttrSelectorWithOptionalNamespace<'i, Impl> {
}
}

#[derive(Clone, Eq, PartialEq)]
#[derive(Clone, Eq, PartialEq, Hash)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
Expand All @@ -42,7 +42,7 @@ pub enum NamespaceConstraint<NamespaceUrl> {
Specific(NamespaceUrl),
}

#[derive(Clone, Eq, PartialEq)]
#[derive(Clone, Eq, PartialEq, Hash)]
pub enum ParsedAttrSelectorOperation<AttrValue> {
Exists,
WithValue {
Expand Down Expand Up @@ -77,7 +77,7 @@ impl<AttrValue> AttrSelectorOperation<AttrValue> {
}
}

#[derive(Clone, Copy, Eq, PartialEq)]
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -139,7 +139,7 @@ impl AttrSelectorOperator {
/// The definition of whitespace per CSS Selectors Level 3 § 4.
pub static SELECTOR_WHITESPACE: &[char] = &[' ', '\t', '\n', '\r', '\x0C'];

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -180,7 +180,7 @@ impl ParsedCaseSensitivity {
}
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum CaseSensitivity {
CaseSensitive,
AsciiCaseInsensitive,
Expand Down
2 changes: 1 addition & 1 deletion selectors/builder.rs
Expand Up @@ -196,7 +196,7 @@ bitflags! {
}
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub struct SpecificityAndFlags {
/// There are two free bits here, since we use ten bits for each specificity
/// kind (id, class, element).
Expand Down
24 changes: 12 additions & 12 deletions selectors/parser.rs
Expand Up @@ -245,13 +245,13 @@ macro_rules! with_bounds {

#[cfg(feature = "serde")]
with_bounds! {
[Clone + PartialEq]
[Clone + PartialEq + Eq + std::hash::Hash]
[From<CowRcStr<'i>> + From<std::borrow::Cow<'i, str>> + AsRef<str>]
}

#[cfg(not(feature = "serde"))]
with_bounds! {
[Clone + PartialEq]
[Clone + PartialEq + Eq + std::hash::Hash]
[From<CowRcStr<'i>>]
}

Expand Down Expand Up @@ -342,7 +342,7 @@ pub trait Parser<'i> {
}
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -676,7 +676,7 @@ pub fn namespace_empty_string<'i, Impl: SelectorImpl<'i>>() -> Impl::NamespaceUr
///
/// This reordering doesn't change the semantics of selector matching, and we
/// handle it in to_css to make it invisible to serialization.
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct Selector<'i, Impl: SelectorImpl<'i>>(SpecificityAndFlags, Vec<Component<'i, Impl>>);

impl<'i, Impl: SelectorImpl<'i>> Selector<'i, Impl> {
Expand Down Expand Up @@ -1093,7 +1093,7 @@ impl<'a, 'i, Impl: SelectorImpl<'i>> Iterator for AncestorIter<'a, 'i, Impl> {
}
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
Expand Down Expand Up @@ -1152,7 +1152,7 @@ impl Combinator {
}

/// An enum for the different types of :nth- pseudoclasses
#[derive(Copy, Clone, Eq, PartialEq)]
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub enum NthType {
Child,
LastChild,
Expand Down Expand Up @@ -1185,7 +1185,7 @@ impl NthType {
/// The properties that comprise an :nth- pseudoclass as of Selectors 3 (e.g.,
/// nth-child(An+B)).
/// https://www.w3.org/TR/selectors-3/#nth-child-pseudo
#[derive(Copy, Clone, Eq, PartialEq)]
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub struct NthSelectorData {
pub ty: NthType,
pub is_function: bool,
Expand Down Expand Up @@ -1283,7 +1283,7 @@ impl NthSelectorData {
/// The properties that comprise an :nth- pseudoclass as of Selectors 4 (e.g.,
/// nth-child(An+B [of S]?)).
/// https://www.w3.org/TR/selectors-4/#nth-child-pseudo
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct NthOfSelectorData<'i, Impl: SelectorImpl<'i>>(NthSelectorData, Box<[Selector<'i, Impl>]>);

impl<'i, Impl: SelectorImpl<'i>> NthOfSelectorData<'i, Impl> {
Expand Down Expand Up @@ -1314,7 +1314,7 @@ impl<'i, Impl: SelectorImpl<'i>> NthOfSelectorData<'i, Impl> {
/// optimal packing and cache performance, see [1].
///
/// [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1357973
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub enum Component<'i, Impl: SelectorImpl<'i>> {
Combinator(Combinator),

Expand Down Expand Up @@ -1546,7 +1546,7 @@ impl<'i, Impl: SelectorImpl<'i>> Component<'i, Impl> {
}
}

#[derive(Clone, Eq, PartialEq)]
#[derive(Clone, Eq, PartialEq, Hash)]
pub struct LocalName<'i, Impl: SelectorImpl<'i>> {
pub name: Impl::LocalName,
pub lower_name: Impl::LocalName,
Expand Down Expand Up @@ -2941,14 +2941,14 @@ pub mod tests {
use std::collections::HashMap;
use std::fmt;

#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum PseudoClass {
Hover,
Active,
Lang(String),
}

#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum PseudoElement {
Before,
After,
Expand Down

0 comments on commit aa083a7

Please sign in to comment.