Skip to content

Commit aa083a7

Browse files
committed
Remove duplicate style rules
Closes parcel-bundler#456
1 parent c5fcb63 commit aa083a7

File tree

11 files changed

+480
-27
lines changed

11 files changed

+480
-27
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ data-encoding = "2.3.2"
5656
lazy_static = "1.4.0"
5757
const-str = "0.3.1"
5858
pathdiff = "0.2.1"
59+
ahash = "0.7.6"
5960
# CLI deps
6061
atty = { version = "0.2", optional = true }
6162
clap = { version = "3.0.6", features = ["derive"], optional = true }

selectors/attr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::parser::SelectorImpl;
66
use cssparser::ToCss;
77
use std::fmt;
88

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

27-
#[derive(Clone, Eq, PartialEq)]
27+
#[derive(Clone, Eq, PartialEq, Hash)]
2828
#[cfg_attr(
2929
feature = "serde",
3030
derive(serde::Serialize, serde::Deserialize),
@@ -42,7 +42,7 @@ pub enum NamespaceConstraint<NamespaceUrl> {
4242
Specific(NamespaceUrl),
4343
}
4444

45-
#[derive(Clone, Eq, PartialEq)]
45+
#[derive(Clone, Eq, PartialEq, Hash)]
4646
pub enum ParsedAttrSelectorOperation<AttrValue> {
4747
Exists,
4848
WithValue {
@@ -77,7 +77,7 @@ impl<AttrValue> AttrSelectorOperation<AttrValue> {
7777
}
7878
}
7979

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

142-
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
142+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
143143
#[cfg_attr(
144144
feature = "serde",
145145
derive(serde::Serialize, serde::Deserialize),
@@ -180,7 +180,7 @@ impl ParsedCaseSensitivity {
180180
}
181181
}
182182

183-
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
183+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
184184
pub enum CaseSensitivity {
185185
CaseSensitive,
186186
AsciiCaseInsensitive,

selectors/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ bitflags! {
196196
}
197197
}
198198

199-
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
199+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
200200
pub struct SpecificityAndFlags {
201201
/// There are two free bits here, since we use ten bits for each specificity
202202
/// kind (id, class, element).

selectors/parser.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,13 @@ macro_rules! with_bounds {
245245

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

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

@@ -342,7 +342,7 @@ pub trait Parser<'i> {
342342
}
343343
}
344344

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

682682
impl<'i, Impl: SelectorImpl<'i>> Selector<'i, Impl> {
@@ -1093,7 +1093,7 @@ impl<'a, 'i, Impl: SelectorImpl<'i>> Iterator for AncestorIter<'a, 'i, Impl> {
10931093
}
10941094
}
10951095

1096-
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
1096+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
10971097
#[cfg_attr(
10981098
feature = "serde",
10991099
derive(serde::Serialize, serde::Deserialize),
@@ -1152,7 +1152,7 @@ impl Combinator {
11521152
}
11531153

11541154
/// An enum for the different types of :nth- pseudoclasses
1155-
#[derive(Copy, Clone, Eq, PartialEq)]
1155+
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
11561156
pub enum NthType {
11571157
Child,
11581158
LastChild,
@@ -1185,7 +1185,7 @@ impl NthType {
11851185
/// The properties that comprise an :nth- pseudoclass as of Selectors 3 (e.g.,
11861186
/// nth-child(An+B)).
11871187
/// https://www.w3.org/TR/selectors-3/#nth-child-pseudo
1188-
#[derive(Copy, Clone, Eq, PartialEq)]
1188+
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
11891189
pub struct NthSelectorData {
11901190
pub ty: NthType,
11911191
pub is_function: bool,
@@ -1283,7 +1283,7 @@ impl NthSelectorData {
12831283
/// The properties that comprise an :nth- pseudoclass as of Selectors 4 (e.g.,
12841284
/// nth-child(An+B [of S]?)).
12851285
/// https://www.w3.org/TR/selectors-4/#nth-child-pseudo
1286-
#[derive(Clone, PartialEq)]
1286+
#[derive(Clone, PartialEq, Eq, Hash)]
12871287
pub struct NthOfSelectorData<'i, Impl: SelectorImpl<'i>>(NthSelectorData, Box<[Selector<'i, Impl>]>);
12881288

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

@@ -1546,7 +1546,7 @@ impl<'i, Impl: SelectorImpl<'i>> Component<'i, Impl> {
15461546
}
15471547
}
15481548

1549-
#[derive(Clone, Eq, PartialEq)]
1549+
#[derive(Clone, Eq, PartialEq, Hash)]
15501550
pub struct LocalName<'i, Impl: SelectorImpl<'i>> {
15511551
pub name: Impl::LocalName,
15521552
pub lower_name: Impl::LocalName,
@@ -2941,14 +2941,14 @@ pub mod tests {
29412941
use std::collections::HashMap;
29422942
use std::fmt;
29432943

2944-
#[derive(Clone, Debug, Eq, PartialEq)]
2944+
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
29452945
pub enum PseudoClass {
29462946
Hover,
29472947
Active,
29482948
Lang(String),
29492949
}
29502950

2951-
#[derive(Clone, Debug, Eq, PartialEq)]
2951+
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
29522952
pub enum PseudoElement {
29532953
Before,
29542954
After,

0 commit comments

Comments
 (0)