Skip to content

Commit 6a39161

Browse files
authored
Remove binop_seperator for rustfmt config + run rustfmt (#232)
Signed-off-by: Nico Burns <[email protected]>
1 parent 8a6763e commit 6a39161

File tree

146 files changed

+2405
-2071
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+2405
-2071
lines changed

malloc_size_of/lib.rs

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,10 @@ impl<T: MallocSizeOf, U> MallocSizeOf for euclid::Rect<T, U> {
604604

605605
impl<T: MallocSizeOf, U> MallocSizeOf for euclid::SideOffsets2D<T, U> {
606606
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
607-
self.top.size_of(ops) +
608-
self.right.size_of(ops) +
609-
self.bottom.size_of(ops) +
610-
self.left.size_of(ops)
607+
self.top.size_of(ops)
608+
+ self.right.size_of(ops)
609+
+ self.bottom.size_of(ops)
610+
+ self.left.size_of(ops)
611611
}
612612
}
613613

@@ -619,33 +619,33 @@ impl<T: MallocSizeOf, U> MallocSizeOf for euclid::Size2D<T, U> {
619619

620620
impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::Transform2D<T, Src, Dst> {
621621
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
622-
self.m11.size_of(ops) +
623-
self.m12.size_of(ops) +
624-
self.m21.size_of(ops) +
625-
self.m22.size_of(ops) +
626-
self.m31.size_of(ops) +
627-
self.m32.size_of(ops)
622+
self.m11.size_of(ops)
623+
+ self.m12.size_of(ops)
624+
+ self.m21.size_of(ops)
625+
+ self.m22.size_of(ops)
626+
+ self.m31.size_of(ops)
627+
+ self.m32.size_of(ops)
628628
}
629629
}
630630

631631
impl<T: MallocSizeOf, Src, Dst> MallocSizeOf for euclid::Transform3D<T, Src, Dst> {
632632
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
633-
self.m11.size_of(ops) +
634-
self.m12.size_of(ops) +
635-
self.m13.size_of(ops) +
636-
self.m14.size_of(ops) +
637-
self.m21.size_of(ops) +
638-
self.m22.size_of(ops) +
639-
self.m23.size_of(ops) +
640-
self.m24.size_of(ops) +
641-
self.m31.size_of(ops) +
642-
self.m32.size_of(ops) +
643-
self.m33.size_of(ops) +
644-
self.m34.size_of(ops) +
645-
self.m41.size_of(ops) +
646-
self.m42.size_of(ops) +
647-
self.m43.size_of(ops) +
648-
self.m44.size_of(ops)
633+
self.m11.size_of(ops)
634+
+ self.m12.size_of(ops)
635+
+ self.m13.size_of(ops)
636+
+ self.m14.size_of(ops)
637+
+ self.m21.size_of(ops)
638+
+ self.m22.size_of(ops)
639+
+ self.m23.size_of(ops)
640+
+ self.m24.size_of(ops)
641+
+ self.m31.size_of(ops)
642+
+ self.m32.size_of(ops)
643+
+ self.m33.size_of(ops)
644+
+ self.m34.size_of(ops)
645+
+ self.m41.size_of(ops)
646+
+ self.m42.size_of(ops)
647+
+ self.m43.size_of(ops)
648+
+ self.m44.size_of(ops)
649649
}
650650
}
651651

@@ -724,27 +724,27 @@ where
724724
Component::Has(ref relative_selectors) => relative_selectors.size_of(ops),
725725
Component::NthOf(ref nth_of_data) => nth_of_data.size_of(ops),
726726
Component::PseudoElement(ref pseudo) => (*pseudo).size_of(ops),
727-
Component::Combinator(..) |
728-
Component::ExplicitAnyNamespace |
729-
Component::ExplicitNoNamespace |
730-
Component::DefaultNamespace(..) |
731-
Component::Namespace(..) |
732-
Component::ExplicitUniversalType |
733-
Component::LocalName(..) |
734-
Component::ID(..) |
735-
Component::Part(..) |
736-
Component::Class(..) |
737-
Component::AttributeInNoNamespaceExists { .. } |
738-
Component::AttributeInNoNamespace { .. } |
739-
Component::Root |
740-
Component::Empty |
741-
Component::Scope |
742-
Component::ImplicitScope |
743-
Component::ParentSelector |
744-
Component::Nth(..) |
745-
Component::Host(None) |
746-
Component::RelativeSelectorAnchor |
747-
Component::Invalid(..) => 0,
727+
Component::Combinator(..)
728+
| Component::ExplicitAnyNamespace
729+
| Component::ExplicitNoNamespace
730+
| Component::DefaultNamespace(..)
731+
| Component::Namespace(..)
732+
| Component::ExplicitUniversalType
733+
| Component::LocalName(..)
734+
| Component::ID(..)
735+
| Component::Part(..)
736+
| Component::Class(..)
737+
| Component::AttributeInNoNamespaceExists { .. }
738+
| Component::AttributeInNoNamespace { .. }
739+
| Component::Root
740+
| Component::Empty
741+
| Component::Scope
742+
| Component::ImplicitScope
743+
| Component::ParentSelector
744+
| Component::Nth(..)
745+
| Component::Host(None)
746+
| Component::RelativeSelectorAnchor
747+
| Component::Invalid(..) => 0,
748748
}
749749
}
750750
}
@@ -819,7 +819,11 @@ malloc_size_of_is_0!(Range<f32>, Range<f64>);
819819

820820
malloc_size_of_is_0!(app_units::Au);
821821

822-
malloc_size_of_is_0!(cssparser::TokenSerializationType, cssparser::SourceLocation, cssparser::SourcePosition);
822+
malloc_size_of_is_0!(
823+
cssparser::TokenSerializationType,
824+
cssparser::SourceLocation,
825+
cssparser::SourcePosition
826+
);
823827

824828
malloc_size_of_is_0!(selectors::OpaqueElement);
825829

rustfmt.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
match_block_trailing_comma = true
2-
binop_separator = "Back"
32
reorder_imports = true

selectors/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ impl AttrSelectorOperator {
128128
!s.is_empty() && case.contains(element_attr_value, attr_selector_value)
129129
},
130130
AttrSelectorOperator::Includes => {
131-
!s.is_empty() &&
132-
element_attr_value
131+
!s.is_empty()
132+
&& element_attr_value
133133
.split(SELECTOR_WHITESPACE)
134134
.any(|part| case.eq(part.as_bytes(), s))
135135
},

selectors/builder.rs

Lines changed: 73 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@
2323
//! Meeting all these constraints without extra memmove traffic during parsing is non-trivial. This
2424
//! module encapsulates those details and presents an easy-to-use API for the parser.
2525
26-
use crate::parser::{Combinator, Component, RelativeSelector, Selector, SelectorImpl, ParseRelative};
26+
use crate::parser::{
27+
Combinator, Component, ParseRelative, RelativeSelector, Selector, SelectorImpl,
28+
};
2729
use crate::sink::Push;
30+
use bitflags::bitflags;
31+
use derive_more::{Add, AddAssign};
2832
use servo_arc::{Arc, ThinArc};
2933
use smallvec::SmallVec;
3034
use std::cmp;
3135
use std::slice;
32-
use bitflags::bitflags;
33-
use derive_more::{Add, AddAssign};
3436

3537
#[cfg(feature = "to_shmem")]
3638
use to_shmem_derive::ToShmem;
@@ -88,9 +90,15 @@ impl<Impl: SelectorImpl> SelectorBuilder<Impl> {
8890

8991
/// Consumes the builder, producing a Selector.
9092
#[inline(always)]
91-
pub fn build(&mut self, parse_relative: ParseRelative) -> ThinArc<SpecificityAndFlags, Component<Impl>> {
93+
pub fn build(
94+
&mut self,
95+
parse_relative: ParseRelative,
96+
) -> ThinArc<SpecificityAndFlags, Component<Impl>> {
9297
// Compute the specificity and flags.
93-
let sf = specificity_and_flags(self.components.iter(), /* for_nesting_parent = */ false);
98+
let sf = specificity_and_flags(
99+
self.components.iter(),
100+
/* for_nesting_parent = */ false,
101+
);
94102
self.build_with_specificity_and_flags(sf, parse_relative)
95103
}
96104

@@ -103,17 +111,23 @@ impl<Impl: SelectorImpl> SelectorBuilder<Impl> {
103111
parse_relative: ParseRelative,
104112
) -> ThinArc<SpecificityAndFlags, Component<Impl>> {
105113
let implicit_addition = match parse_relative {
106-
ParseRelative::ForNesting if !spec.flags.intersects(SelectorFlags::HAS_PARENT) => Some((Component::ParentSelector, SelectorFlags::HAS_PARENT)),
107-
ParseRelative::ForScope if !spec.flags.intersects(SelectorFlags::HAS_SCOPE | SelectorFlags::HAS_PARENT) => Some((Component::ImplicitScope, SelectorFlags::HAS_SCOPE)),
114+
ParseRelative::ForNesting if !spec.flags.intersects(SelectorFlags::HAS_PARENT) => {
115+
Some((Component::ParentSelector, SelectorFlags::HAS_PARENT))
116+
},
117+
ParseRelative::ForScope
118+
if !spec
119+
.flags
120+
.intersects(SelectorFlags::HAS_SCOPE | SelectorFlags::HAS_PARENT) =>
121+
{
122+
Some((Component::ImplicitScope, SelectorFlags::HAS_SCOPE))
123+
},
108124
_ => None,
109125
};
110126
let implicit_selector_and_combinator;
111127
let implicit_selector = if let Some((component, flag)) = implicit_addition {
112128
spec.flags.insert(flag);
113-
implicit_selector_and_combinator = [
114-
Component::Combinator(Combinator::Descendant),
115-
component,
116-
];
129+
implicit_selector_and_combinator =
130+
[Component::Combinator(Combinator::Descendant), component];
117131
&implicit_selector_and_combinator[..]
118132
} else {
119133
&[]
@@ -122,15 +136,23 @@ impl<Impl: SelectorImpl> SelectorBuilder<Impl> {
122136
// As an optimization, for a selector without combinators, we can just keep the order
123137
// as-is.
124138
if self.last_compound_start.is_none() {
125-
return Arc::from_header_and_iter(spec, ExactChain(self.components.drain(..), implicit_selector.iter().cloned()));
139+
return Arc::from_header_and_iter(
140+
spec,
141+
ExactChain(self.components.drain(..), implicit_selector.iter().cloned()),
142+
);
126143
}
127144

128145
self.reverse_last_compound();
129-
Arc::from_header_and_iter(spec, ExactChain(self.components.drain(..).rev(), implicit_selector.iter().cloned()))
146+
Arc::from_header_and_iter(
147+
spec,
148+
ExactChain(
149+
self.components.drain(..).rev(),
150+
implicit_selector.iter().cloned(),
151+
),
152+
)
130153
}
131154
}
132155

133-
134156
impl<Impl: SelectorImpl> Default for SelectorBuilder<Impl> {
135157
#[inline(always)]
136158
fn default() -> Self {
@@ -257,9 +279,9 @@ impl From<u32> for Specificity {
257279
impl From<Specificity> for u32 {
258280
#[inline]
259281
fn from(specificity: Specificity) -> u32 {
260-
cmp::min(specificity.id_selectors, MAX_10BIT) << 20 |
261-
cmp::min(specificity.class_like_selectors, MAX_10BIT) << 10 |
262-
cmp::min(specificity.element_selectors, MAX_10BIT)
282+
cmp::min(specificity.id_selectors, MAX_10BIT) << 20
283+
| cmp::min(specificity.class_like_selectors, MAX_10BIT) << 10
284+
| cmp::min(specificity.element_selectors, MAX_10BIT)
263285
}
264286
}
265287

@@ -304,9 +326,7 @@ where
304326
specificity.element_selectors += pseudo.specificity_count();
305327
}
306328
},
307-
Component::LocalName(..) => {
308-
specificity.element_selectors += 1
309-
},
329+
Component::LocalName(..) => specificity.element_selectors += 1,
310330
Component::Slotted(ref selector) => {
311331
flags.insert(SelectorFlags::HAS_SLOTTED);
312332
if !for_nesting_parent {
@@ -333,14 +353,14 @@ where
333353
Component::ID(..) => {
334354
specificity.id_selectors += 1;
335355
},
336-
Component::Class(..) |
337-
Component::AttributeInNoNamespace { .. } |
338-
Component::AttributeInNoNamespaceExists { .. } |
339-
Component::AttributeOther(..) |
340-
Component::Root |
341-
Component::Empty |
342-
Component::Nth(..) |
343-
Component::NonTSPseudoClass(..) => {
356+
Component::Class(..)
357+
| Component::AttributeInNoNamespace { .. }
358+
| Component::AttributeInNoNamespaceExists { .. }
359+
| Component::AttributeOther(..)
360+
| Component::Root
361+
| Component::Empty
362+
| Component::Nth(..)
363+
| Component::NonTSPseudoClass(..) => {
344364
specificity.class_like_selectors += 1;
345365
},
346366
Component::Scope | Component::ImplicitScope => {
@@ -357,7 +377,10 @@ where
357377
// specificity of a regular pseudo-class with that of its
358378
// selector argument S.
359379
specificity.class_like_selectors += 1;
360-
let sf = selector_list_specificity_and_flags(nth_of_data.selectors().iter(), for_nesting_parent);
380+
let sf = selector_list_specificity_and_flags(
381+
nth_of_data.selectors().iter(),
382+
for_nesting_parent,
383+
);
361384
*specificity += Specificity::from(sf.specificity);
362385
flags.insert(sf.flags);
363386
},
@@ -366,27 +389,33 @@ where
366389
// The specificity of an :is(), :not(), or :has() pseudo-class
367390
// is replaced by the specificity of the most specific complex
368391
// selector in its selector list argument.
369-
Component::Where(ref list) |
370-
Component::Negation(ref list) |
371-
Component::Is(ref list) => {
372-
let sf = selector_list_specificity_and_flags(list.slice().iter(), /* nested = */ true);
392+
Component::Where(ref list)
393+
| Component::Negation(ref list)
394+
| Component::Is(ref list) => {
395+
let sf = selector_list_specificity_and_flags(
396+
list.slice().iter(),
397+
/* nested = */ true,
398+
);
373399
if !matches!(*simple_selector, Component::Where(..)) {
374400
*specificity += Specificity::from(sf.specificity);
375401
}
376402
flags.insert(sf.flags);
377403
},
378404
Component::Has(ref relative_selectors) => {
379-
let sf = relative_selector_list_specificity_and_flags(relative_selectors, for_nesting_parent);
405+
let sf = relative_selector_list_specificity_and_flags(
406+
relative_selectors,
407+
for_nesting_parent,
408+
);
380409
*specificity += Specificity::from(sf.specificity);
381410
flags.insert(sf.flags);
382411
},
383-
Component::ExplicitUniversalType |
384-
Component::ExplicitAnyNamespace |
385-
Component::ExplicitNoNamespace |
386-
Component::DefaultNamespace(..) |
387-
Component::Namespace(..) |
388-
Component::RelativeSelectorAnchor |
389-
Component::Invalid(..) => {
412+
Component::ExplicitUniversalType
413+
| Component::ExplicitAnyNamespace
414+
| Component::ExplicitNoNamespace
415+
| Component::DefaultNamespace(..)
416+
| Component::Namespace(..)
417+
| Component::RelativeSelectorAnchor
418+
| Component::Invalid(..) => {
390419
// Does not affect specificity
391420
},
392421
}
@@ -417,7 +446,9 @@ pub(crate) fn selector_list_specificity_and_flags<'a, Impl: SelectorImpl>(
417446
let mut flags = SelectorFlags::empty();
418447
for selector in itr {
419448
let selector_flags = selector.flags();
420-
let selector_specificity = if for_nesting_parent && selector_flags.intersects(SelectorFlags::forbidden_for_nesting()) {
449+
let selector_specificity = if for_nesting_parent
450+
&& selector_flags.intersects(SelectorFlags::forbidden_for_nesting())
451+
{
421452
// In this case we need to re-compute the specificity.
422453
specificity_and_flags(selector.iter_raw_match_order(), for_nesting_parent).specificity
423454
} else {

0 commit comments

Comments
 (0)