style: Reformat recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2019-04-11 22:12:41 +02:00
parent 7c4f9bbf49
commit 8c004c0858
40 changed files with 571 additions and 212 deletions

View file

@ -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) })