Format with rustfmt 2019-09-08

This commit is contained in:
David Tolnay 2019-10-09 18:43:49 -07:00
parent 4118197eac
commit a727067a7d
2 changed files with 13 additions and 4 deletions

View File

@ -233,7 +233,9 @@ impl Error {
if self.is::<E>() { if self.is::<E>() {
let outer = ManuallyDrop::new(self); let outer = ManuallyDrop::new(self);
unsafe { unsafe {
let error = ptr::read(outer.inner.error() as *const (dyn StdError + Send + Sync) as *const E); let error = ptr::read(
outer.inner.error() as *const (dyn StdError + Send + Sync) as *const E
);
let inner = ptr::read(&outer.inner); let inner = ptr::read(&outer.inner);
let erased = ManuallyDrop::into_inner(inner); let erased = ManuallyDrop::into_inner(inner);
(erased.vtable.object_drop_front)(erased); (erased.vtable.object_drop_front)(erased);
@ -285,7 +287,9 @@ impl Error {
E: Display + Debug + Send + Sync + 'static, E: Display + Debug + Send + Sync + 'static,
{ {
if self.is::<E>() { if self.is::<E>() {
Some(unsafe { &*(self.inner.error() as *const (dyn StdError + Send + Sync) as *const E) }) Some(unsafe {
&*(self.inner.error() as *const (dyn StdError + Send + Sync) as *const E)
})
} else { } else {
None None
} }
@ -297,7 +301,9 @@ impl Error {
E: Display + Debug + Send + Sync + 'static, E: Display + Debug + Send + Sync + 'static,
{ {
if self.is::<E>() { if self.is::<E>() {
Some(unsafe { &mut *(self.inner.error_mut() as *mut (dyn StdError + Send + Sync) as *mut E) }) Some(unsafe {
&mut *(self.inner.error_mut() as *mut (dyn StdError + Send + Sync) as *mut E)
})
} else { } else {
None None
} }

View File

@ -94,5 +94,8 @@ fn test_large_alignment() {
impl StdError for LargeAlignedError {} impl StdError for LargeAlignedError {}
let error = Error::new(LargeAlignedError("oh no!")); let error = Error::new(LargeAlignedError("oh no!"));
assert_eq!("oh no!", error.downcast_ref::<LargeAlignedError>().unwrap().0); assert_eq!(
"oh no!",
error.downcast_ref::<LargeAlignedError>().unwrap().0
);
} }