diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-04-11 22:12:41 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-04-12 12:20:14 +0200 |
commit | 8c004c08580287172585169807ed36933ad674f8 (patch) | |
tree | 36b6b6288ee034ec688e2678f29f6c2445ebc548 /components/to_shmem | |
parent | 7c4f9bbf494387c2046d614f5d8769b7ce7eed67 (diff) | |
download | servo-8c004c08580287172585169807ed36933ad674f8.tar.gz servo-8c004c08580287172585169807ed36933ad674f8.zip |
style: Reformat recent changes.
Diffstat (limited to 'components/to_shmem')
-rw-r--r-- | components/to_shmem/lib.rs | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/components/to_shmem/lib.rs b/components/to_shmem/lib.rs index db6efe20895..59fc2afb546 100644 --- a/components/to_shmem/lib.rs +++ b/components/to_shmem/lib.rs @@ -24,17 +24,17 @@ use smallvec::{Array, SmallVec}; use std::alloc::Layout; #[cfg(debug_assertions)] use std::any::TypeId; -use std::isize; #[cfg(debug_assertions)] use std::collections::HashSet; use std::ffi::CString; +use std::isize; use std::marker::PhantomData; use std::mem::{self, ManuallyDrop}; use std::num::Wrapping; use std::ops::Range; +use std::os::raw::c_char; #[cfg(debug_assertions)] use std::os::raw::c_void; -use std::os::raw::c_char; use std::ptr::{self, NonNull}; use std::slice; use std::str; @@ -166,7 +166,7 @@ impl SharedMemoryBuilder { // Reserve space for the padding. let start = self.index.checked_add(padding).unwrap(); - assert!(start <= std::isize::MAX as usize); // for the cast below + assert!(start <= std::isize::MAX as usize); // for the cast below // Reserve space for the value. let end = start.checked_add(layout.size()).unwrap(); @@ -205,7 +205,22 @@ macro_rules! impl_trivial_to_shmem { )*}; } -impl_trivial_to_shmem!((), bool, f32, f64, i8, i16, i32, i64, u8, u16, u32, u64, isize, usize); +impl_trivial_to_shmem!( + (), + bool, + f32, + f64, + i8, + i16, + i32, + i64, + u8, + u16, + u32, + u64, + isize, + usize +); impl_trivial_to_shmem!(cssparser::RGBA); impl_trivial_to_shmem!(cssparser::SourceLocation); @@ -424,7 +439,9 @@ impl<T: 'static + ToShmem> ToShmem for Arc<T> { #[cfg(debug_assertions)] assert!( !builder.shared_values.contains(&self.heap_ptr()) || - builder.allowed_duplication_types.contains(&TypeId::of::<T>()), + builder + .allowed_duplication_types + .contains(&TypeId::of::<T>()), "ToShmem failed for Arc<T>: encountered a value of type T with multiple references \ and which has not been explicitly allowed with an add_allowed_duplication_type call", ); @@ -463,11 +480,7 @@ impl<H: 'static + ToShmem, T: 'static + ToShmem> ToShmem for ThinArc<H, T> { // Make a clone of the Arc-owned header and slice values with all of // their heap allocations placed in the shared memory buffer. let header = self.header.header.to_shmem(builder); - let values: Vec<ManuallyDrop<T>> = self - .slice - .iter() - .map(|v| v.to_shmem(builder)) - .collect(); + let values: Vec<ManuallyDrop<T>> = self.slice.iter().map(|v| v.to_shmem(builder)).collect(); // Create a new ThinArc with the shared value and have it place // its ArcInner in the shared memory buffer. @@ -499,10 +512,11 @@ impl ToShmem for SmallBitVec { let src = vs.as_ptr() as *const usize; ptr::copy(src, dest, len); - let dest_slice = Box::from_raw(slice::from_raw_parts_mut(dest, len) as *mut [usize]); + let dest_slice = + Box::from_raw(slice::from_raw_parts_mut(dest, len) as *mut [usize]); InternalStorage::Spilled(dest_slice) } - } + }, InternalStorage::Inline(x) => InternalStorage::Inline(x), }; ManuallyDrop::new(unsafe { SmallBitVec::from_storage(storage) }) |