Skip to content
Myr

Explicitly specify all cast types in unsafe code

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent d57f80c · Browse files · 1 file+3 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−3 removed

  • other:+3 added−3 removed

1 file+3 added−3 removed

modified:src/error.rs+3 added-3 removed
231 unmodified lines
232 {233 if self.is::<E>() {234 let outer = ManuallyDrop::new(self);235 unsafe {236 let error = ptr::read(outer.inner.error() as *const _ as *const E);236 let error = ptr::read(outer.inner.error() as *const (dyn StdError + Send + Sync) as *const E);237 let inner = ptr::read(&outer.inner);238 let erased = ManuallyDrop::into_inner(inner);239 (erased.vtable.object_drop_front)(erased);240 Ok(error)
43 unmodified lines
284 where285 E: Display + Debug + Send + Sync + 'static,286 {287 if self.is::<E>() {288 Some(unsafe { &*(self.inner.error() as *const _ as *const E) })288 Some(unsafe { &*(self.inner.error() as *const (dyn StdError + Send + Sync) as *const E) })289 } else {290 None291 }292 }
3 unmodified lines
296 where297 E: Display + Debug + Send + Sync + 'static,298 {299 if self.is::<E>() {300 Some(unsafe { &mut *(self.inner.error_mut() as *mut _ as *mut E) })300 Some(unsafe { &mut *(self.inner.error_mut() as *mut (dyn StdError + Send + Sync) as *mut E) })301 } else {302 None303 }304 }
296 unmodified lines