Bug 1519729 - Rustfmt recent changes.
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 13 Jan 2019 21:49:46 +0100
changeset 453677 7ccafc4ab34ce5980b056c72f7e1a91f34320626
parent 453676 1a1d8b9f1a3ab704ab277407823f6f42dd63a3d4
child 453681 4df878f3d0371bff46f41e9fc570c73bd29919da
push id111121
push useremilio@crisal.io
push dateSun, 13 Jan 2019 20:57:57 +0000
treeherdermozilla-inbound@7ccafc4ab34c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1519729
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1519729 - Rustfmt recent changes.
servo/components/style/values/animated/grid.rs
servo/components/style/values/computed/box.rs
servo/components/style/values/generics/grid.rs
servo/components/style/values/specified/mod.rs
servo/components/style_derive/animate.rs
--- a/servo/components/style/values/animated/grid.rs
+++ b/servo/components/style/values/animated/grid.rs
@@ -6,58 +6,62 @@
 
 // Note: we can implement Animate on their generic types directly, but in this case we need to
 // make sure two trait bounds, L: Clone and I: PartialEq, are satisfied on almost all the
 // grid-related types and their other trait implementations because Animate needs them. So in
 // order to avoid adding these two trait bounds (or maybe more..) everywhere, we implement
 // Animate for the computed types, instead of the generic types.
 
 use super::{Animate, Procedure, ToAnimatedZero};
-use crate::values::computed::{GridTemplateComponent, TrackList, TrackSize};
 use crate::values::computed::Integer;
 use crate::values::computed::LengthPercentage;
+use crate::values::computed::{GridTemplateComponent, TrackList, TrackSize};
 use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
 use crate::values::generics::grid as generics;
 
 fn discrete<T: Clone>(from: &T, to: &T, procedure: Procedure) -> Result<T, ()> {
     if let Procedure::Interpolate { progress } = procedure {
-        Ok(if progress < 0.5 { from.clone() } else { to.clone() })
+        Ok(if progress < 0.5 {
+            from.clone()
+        } else {
+            to.clone()
+        })
     } else {
         Err(())
     }
 }
 
 fn animate_with_discrete_fallback<T: Animate + Clone>(
     from: &T,
     to: &T,
-    procedure: Procedure
+    procedure: Procedure,
 ) -> Result<T, ()> {
-    from.animate(to, procedure).or_else(|_| discrete(from, to, procedure))
+    from.animate(to, procedure)
+        .or_else(|_| discrete(from, to, procedure))
 }
 
 impl Animate for TrackSize {
     fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
         match (self, other) {
-            (&generics::TrackSize::Breadth(ref from),
-             &generics::TrackSize::Breadth(ref to)) => {
+            (&generics::TrackSize::Breadth(ref from), &generics::TrackSize::Breadth(ref to)) => {
                 animate_with_discrete_fallback(from, to, procedure)
                     .map(generics::TrackSize::Breadth)
             },
-            (&generics::TrackSize::Minmax(ref from_min, ref from_max),
-             &generics::TrackSize::Minmax(ref to_min, ref to_max)) => {
-                Ok(generics::TrackSize::Minmax(
-                    animate_with_discrete_fallback(from_min, to_min, procedure)?,
-                    animate_with_discrete_fallback(from_max, to_max, procedure)?,
-                ))
-            },
-            (&generics::TrackSize::FitContent(ref from),
-             &generics::TrackSize::FitContent(ref to)) => {
-                animate_with_discrete_fallback(from, to, procedure)
-                    .map(generics::TrackSize::FitContent)
-            },
+            (
+                &generics::TrackSize::Minmax(ref from_min, ref from_max),
+                &generics::TrackSize::Minmax(ref to_min, ref to_max),
+            ) => Ok(generics::TrackSize::Minmax(
+                animate_with_discrete_fallback(from_min, to_min, procedure)?,
+                animate_with_discrete_fallback(from_max, to_max, procedure)?,
+            )),
+            (
+                &generics::TrackSize::FitContent(ref from),
+                &generics::TrackSize::FitContent(ref to),
+            ) => animate_with_discrete_fallback(from, to, procedure)
+                .map(generics::TrackSize::FitContent),
             (_, _) => discrete(self, other, procedure),
         }
     }
 }
 
 impl Animate for generics::TrackRepeat<LengthPercentage, Integer>
 where
     generics::RepeatCount<Integer>: PartialEq,
@@ -67,38 +71,46 @@ where
         // number of tracks. For both auto-fit/fill, the number of columns isn't
         // known until you do layout since it depends on the container size, item
         // placement and other factors, so we cannot do the correct interpolation
         // by computed values. Therefore, return Err(()) if it's keywords. If it
         // is Number, we support animation only if the count is the same and the
         // length of track_sizes is the same.
         // https://github.com/w3c/csswg-drafts/issues/3503
         match (&self.count, &other.count) {
-            (&generics::RepeatCount::Number(from),
-             &generics::RepeatCount::Number(to)) if from == to => (),
+            (&generics::RepeatCount::Number(from), &generics::RepeatCount::Number(to))
+                if from == to =>
+            {
+                ()
+            },
             (_, _) => return Err(()),
         }
 
         // The length of track_sizes should be matched.
         if self.track_sizes.len() != other.track_sizes.len() {
             return Err(());
         }
 
         let count = self.count;
-        let track_sizes = self.track_sizes
+        let track_sizes = self
+            .track_sizes
             .iter()
             .zip(other.track_sizes.iter())
             .map(|(a, b)| a.animate(b, procedure))
             .collect::<Result<Vec<_>, _>>()?;
 
         // The length of |line_names| is always 0 or N+1, where N is the length
         // of |track_sizes|. Besides, <line-names> is always discrete.
         let line_names = discrete(&self.line_names, &other.line_names, procedure)?;
 
-        Ok(generics::TrackRepeat { count, line_names, track_sizes })
+        Ok(generics::TrackRepeat {
+            count,
+            line_names,
+            track_sizes,
+        })
     }
 }
 
 impl Animate for TrackList {
     // Based on https://github.com/w3c/csswg-drafts/issues/3201:
     // 1. Check interpolation type per track, so we need to handle discrete animations
     //    in TrackSize, so any Err(()) returned from TrackSize doesn't make all TrackSize
     //    fallback to discrete animation.
@@ -117,26 +129,32 @@ impl Animate for TrackList {
         // traversing |values| in <auto-track-list>. This may be updated in the future.
         // https://github.com/w3c/csswg-drafts/issues/3503
         if let generics::TrackListType::Auto(_) = self.list_type {
             return Err(());
         }
 
         let list_type = self.list_type;
         let auto_repeat = self.auto_repeat.animate(&other.auto_repeat, procedure)?;
-        let values = self.values
+        let values = self
+            .values
             .iter()
             .zip(other.values.iter())
             .map(|(a, b)| a.animate(b, procedure))
             .collect::<Result<Vec<_>, _>>()?;
         // The length of |line_names| is always 0 or N+1, where N is the length
         // of |track_sizes|. Besides, <line-names> is always discrete.
         let line_names = discrete(&self.line_names, &other.line_names, procedure)?;
 
-        Ok(TrackList { list_type, values, line_names, auto_repeat })
+        Ok(TrackList {
+            list_type,
+            values,
+            line_names,
+            auto_repeat,
+        })
     }
 }
 
 impl ComputeSquaredDistance for GridTemplateComponent {
     #[inline]
     fn compute_squared_distance(&self, _other: &Self) -> Result<SquaredDistance, ()> {
         // TODO: Bug 1518585, we should implement ComputeSquaredDistance.
         Err(())
--- a/servo/components/style/values/computed/box.rs
+++ b/servo/components/style/values/computed/box.rs
@@ -8,17 +8,18 @@ use crate::values::computed::length::{Le
 use crate::values::computed::{Context, Number, ToComputedValue};
 use crate::values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
 use crate::values::generics::box_::Perspective as GenericPerspective;
 use crate::values::generics::box_::VerticalAlign as GenericVerticalAlign;
 use crate::values::specified::box_ as specified;
 
 pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween, BreakWithin};
 pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat};
-pub use crate::values::specified::box_::{Contain, Display, Overflow, OverflowAnchor, OverflowClipBox};
+pub use crate::values::specified::box_::{Contain, Display, Overflow};
+pub use crate::values::specified::box_::{OverflowAnchor, OverflowClipBox};
 pub use crate::values::specified::box_::{OverscrollBehavior, ScrollSnapType};
 pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange};
 
 /// A computed value for the `vertical-align` property.
 pub type VerticalAlign = GenericVerticalAlign<LengthPercentage>;
 
 /// A computed value for the `animation-iteration-count` property.
 pub type AnimationIterationCount = GenericAnimationIterationCount<Number>;
--- a/servo/components/style/values/generics/grid.rs
+++ b/servo/components/style/values/generics/grid.rs
@@ -169,24 +169,17 @@ pub enum TrackKeyword {
     MinContent,
 }
 
 /// A track breadth for explicit grid track sizing. It's generic solely to
 /// avoid re-implementing it for the computed type.
 ///
 /// <https://drafts.csswg.org/css-grid/#typedef-track-breadth>
 #[derive(
-    Animate,
-    Clone,
-    Debug,
-    MallocSizeOf,
-    PartialEq,
-    SpecifiedValueInfo,
-    ToComputedValue,
-    ToCss,
+    Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
 )]
 pub enum TrackBreadth<L> {
     /// The generic type is almost always a non-negative `<length-percentage>`
     Breadth(L),
     /// A flex fraction specified in `fr` units.
     #[css(dimension)]
     Fr(CSSFloat),
     /// One of the track-sizing keywords (`auto`, `min-content`, `max-content`)
@@ -487,24 +480,17 @@ impl<L: Clone> TrackRepeat<L, specified:
                 line_names: self.line_names.clone(),
             }
         }
     }
 }
 
 /// Track list values. Can be <track-size> or <track-repeat>
 #[derive(
-    Animate,
-    Clone,
-    Debug,
-    MallocSizeOf,
-    PartialEq,
-    SpecifiedValueInfo,
-    ToComputedValue,
-    ToCss
+    Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
 )]
 pub enum TrackListValue<LengthPercentage, Integer> {
     /// A <track-size> value.
     TrackSize(#[animation(field_bound)] TrackSize<LengthPercentage>),
     /// A <track-repeat> value.
     TrackRepeat(#[animation(field_bound)] TrackRepeat<LengthPercentage, Integer>),
 }
 
@@ -707,30 +693,27 @@ impl ToCss for LineNameList {
         Ok(())
     }
 }
 
 /// Variants for `<grid-template-rows> | <grid-template-columns>`
 /// Subgrid deferred to Level 2 spec due to lack of implementation.
 /// But it's implemented in gecko, so we have to as well.
 #[derive(
-    Animate,
-    Clone,
-    Debug,
-    MallocSizeOf,
-    PartialEq,
-    SpecifiedValueInfo,
-    ToComputedValue,
-    ToCss
+    Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
 )]
 pub enum GridTemplateComponent<L, I> {
     /// `none` value.
     None,
     /// The grid `<track-list>`
-    TrackList(#[animation(field_bound)] #[compute(field_bound)] TrackList<L, I>),
+    TrackList(
+        #[animation(field_bound)]
+        #[compute(field_bound)]
+        TrackList<L, I>,
+    ),
     /// A `subgrid <line-name-list>?`
     /// TODO: Support animations for this after subgrid is addressed in [grid-2] spec.
     #[animation(error)]
     Subgrid(LineNameList),
 }
 
 impl<L, I> GridTemplateComponent<L, I> {
     /// Returns length of the <track-list>s <track-size>
--- a/servo/components/style/values/specified/mod.rs
+++ b/servo/components/style/values/specified/mod.rs
@@ -31,17 +31,18 @@ pub use self::align::{AlignContent, Alig
 pub use self::align::{JustifyContent, JustifyItems, JustifySelf, SelfAlignment};
 pub use self::angle::Angle;
 pub use self::background::{BackgroundRepeat, BackgroundSize};
 pub use self::basic_shape::FillRule;
 pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
 pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
 pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle};
 pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
-pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float, Overflow, OverflowAnchor};
+pub use self::box_::{Appearance, BreakBetween, BreakWithin};
+pub use self::box_::{Clear, Float, Overflow, OverflowAnchor};
 pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
 pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange};
 pub use self::color::{Color, ColorPropertyValue, RGBAColor};
 pub use self::column::ColumnCount;
 pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset};
 pub use self::easing::TimingFunction;
 pub use self::effects::{BoxShadow, Filter, SimpleShadow};
 pub use self::flex::FlexBasis;
--- a/servo/components/style_derive/animate.rs
+++ b/servo/components/style_derive/animate.rs
@@ -83,17 +83,20 @@ fn derive_variant_arm(
     let (other_pattern, other_info) = cg::ref_pattern(&variant, "other");
     let (result_value, result_info) = cg::value(&variant, "result");
     let mut computations = quote!();
     let iter = result_info.iter().zip(this_info.iter().zip(&other_info));
     computations.append_all(iter.map(|(result, (this, other))| {
         let field_attrs = cg::parse_field_attrs::<AnimationFieldAttrs>(&result.ast());
         if field_attrs.field_bound {
             let ty = &this.ast().ty;
-            cg::add_predicate(where_clause, parse_quote!(#ty: crate::values::animated::Animate));
+            cg::add_predicate(
+                where_clause,
+                parse_quote!(#ty: crate::values::animated::Animate),
+            );
         }
         if field_attrs.constant {
             quote! {
                 if #this != #other {
                     return Err(());
                 }
                 let #result = std::clone::Clone::clone(#this);
             }