Skip to content
Permalink
Browse files

style: Rustfmt + build fix.

  • Loading branch information...
emilio committed May 9, 2019
1 parent f429c28 commit db2f6aa8ca1f23f78a497cb7cc960ff99f23ac04
@@ -687,7 +687,10 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> {
}
// We should have consumed the buffer exactly, maybe accounting
// for some padding from the alignment.
debug_assert!((buffer.offset(size as isize) as usize - current as *mut u8 as usize) < align_of::<Self>());
debug_assert!(
(buffer.offset(size as isize) as usize - current as *mut u8 as usize) <
align_of::<Self>()
);
}
assert!(
items.next().is_none(),
@@ -792,7 +795,6 @@ pub struct ThinArc<H, T> {
phantom: PhantomData<(H, T)>,
}


impl<H: fmt::Debug, T: fmt::Debug> fmt::Debug for ThinArc<H, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(self.deref(), f)
@@ -909,7 +911,10 @@ impl<H, T> Clone for ThinArc<H, T> {
impl<H, T> Drop for ThinArc<H, T> {
#[inline]
fn drop(&mut self) {
let _ = Arc::from_thin(ThinArc { ptr: self.ptr, phantom: PhantomData, });
let _ = Arc::from_thin(ThinArc {
ptr: self.ptr,
phantom: PhantomData,
});
}
}

@@ -928,7 +933,9 @@ impl<H, T> Arc<HeaderSliceWithLength<H, [T]>> {
let thin_ptr = fat_ptr as *mut [usize] as *mut usize;
ThinArc {
ptr: unsafe {
ptr::NonNull::new_unchecked(thin_ptr as *mut ArcInner<HeaderSliceWithLength<H, [T; 0]>>)
ptr::NonNull::new_unchecked(
thin_ptr as *mut ArcInner<HeaderSliceWithLength<H, [T; 0]>>,
)
},
phantom: PhantomData,
}
@@ -536,12 +536,10 @@ pub mod basic_shape {
StyleGeometryBox, StyleShapeSource, StyleShapeSourceType,
};
use crate::gecko_bindings::sugar::refptr::RefPtr;
use crate::values::computed::basic_shape::{
BasicShape, ClippingShape, FloatAreaShape,
};
use crate::values::computed::basic_shape::{BasicShape, ClippingShape, FloatAreaShape};
use crate::values::computed::motion::OffsetPath;
use crate::values::computed::url::ComputedUrl;
use crate::values::generics::basic_shape::{Path, GeometryBox, ShapeBox, ShapeSource};
use crate::values::generics::basic_shape::{GeometryBox, Path, ShapeBox, ShapeSource};
use crate::values::specified::SVGPathData;

impl StyleShapeSource {
@@ -7,8 +7,8 @@
//! Different kind of helpers to interact with Gecko values.

use crate::counter_style::{Symbol, Symbols};
use crate::gecko_bindings::structs::{nsStyleCoord, CounterStylePtr};
use crate::gecko_bindings::structs::StyleGridTrackBreadth;
use crate::gecko_bindings::structs::{nsStyleCoord, CounterStylePtr};
use crate::gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
use crate::values::computed::{Angle, Length, LengthPercentage};
use crate::values::computed::{Number, NumberOrPercentage, Percentage};
@@ -680,5 +680,6 @@ ${helpers.predefined_type(
"Either::Second(None_)",
gecko_pref="layout.css.webkit-line-clamp.enabled",
animation_value_type="Integer",
products="gecko",
spec="https://drafts.csswg.org/css-overflow-3/#line-clamp",
)}
@@ -298,7 +298,6 @@ where
}
}


impl<T> ToAnimatedValue for Box<[T]>
where
T: ToAnimatedValue,
@@ -307,8 +306,7 @@ where

#[inline]
fn to_animated_value(self) -> Self::AnimatedValue {
self
.into_vec()
self.into_vec()
.into_iter()
.map(T::to_animated_value)
.collect::<Vec<_>>()
@@ -352,12 +352,14 @@ impl Polygon {
})
.unwrap_or_default();

let coordinates = input.parse_comma_separated(|i| {
Ok(PolygonCoord(
LengthPercentage::parse(context, i)?,
LengthPercentage::parse(context, i)?,
))
})?.into();
let coordinates = input
.parse_comma_separated(|i| {
Ok(PolygonCoord(
LengthPercentage::parse(context, i)?,
LengthPercentage::parse(context, i)?,
))
})?
.into();

Ok(Polygon { fill, coordinates })
}
@@ -33,8 +33,7 @@ use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
pub struct SVGPathData(
// TODO(emilio): Should probably measure this somehow only from the
// specified values.
#[ignore_malloc_size_of = "Arc"]
pub crate::ArcSlice<PathCommand>
#[ignore_malloc_size_of = "Arc"] pub crate::ArcSlice<PathCommand>,
);

impl SVGPathData {
@@ -103,7 +102,9 @@ impl Parse for SVGPathData {
}
}

Ok(SVGPathData(crate::ArcSlice::from_iter(path_parser.path.into_iter())))
Ok(SVGPathData(crate::ArcSlice::from_iter(
path_parser.path.into_iter(),
)))
}
}

@@ -21,7 +21,7 @@ const ARC_SLICE_CANARY: u32 = 0xf3f3f3f3;
/// cbindgen:derive-eq=false
/// cbindgen:derive-neq=false
#[repr(C)]
#[derive(Debug, Clone, PartialEq, Eq, ToShmem)]
#[derive(Clone, Debug, Eq, PartialEq, ToShmem)]
pub struct ArcSlice<T>(#[shmem(field_bound)] ThinArc<u32, T>);

impl<T> Deref for ArcSlice<T> {
@@ -6,11 +6,11 @@

//! A replacement for `Box<[T]>` that cbindgen can understand.

use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps};
use std::marker::PhantomData;
use std::{fmt, mem, slice};
use std::ptr::NonNull;
use std::ops::{Deref, DerefMut};
use malloc_size_of::{MallocSizeOf, MallocShallowSizeOf, MallocSizeOfOps};
use std::ptr::NonNull;
use std::{fmt, mem, slice};
use to_shmem::{SharedMemoryBuilder, ToShmem};

/// A struct that basically replaces a `Box<[T]>`, but which cbindgen can
@@ -86,9 +86,7 @@ impl<T: Sized> OwnedSlice<T> {
/// Convert the OwnedSlice into a Vec.
#[inline]
pub fn into_vec(self) -> Vec<T> {
let ret = unsafe {
Vec::from_raw_parts(self.ptr.as_ptr(), self.len, self.len)
};
let ret = unsafe { Vec::from_raw_parts(self.ptr.as_ptr(), self.len, self.len) };
mem::forget(self);
ret
}

0 comments on commit db2f6aa

Please sign in to comment.
You can’t perform that action at this time.