Skip to content
Myr

Rename vtable object ref and mut methods that are no longer raw ptr

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 eeaf2ef · Browse files · 1 file+8 added−8 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+8 added−8 removed

  • other:+8 added−8 removed

1 file+8 added−8 removed

modified:src/error.rs+8 added-8 removed
81 unmodified lines
82 {83 let vtable = &ErrorVTable {84 object_drop: object_drop::<E>,85 object_drop_front: object_drop_front::<E>,86 object_raw: object_raw::<E>,87 object_mut_raw: object_mut_raw::<E>,86 object_ref: object_ref::<E>,87 object_mut: object_mut::<E>,88 object_boxed: object_boxed::<E>,89 };90 let inner = Box::new(ErrorImpl {91 vtable,
263 unmodified lines
355356struct ErrorVTable {357 object_drop: unsafe fn(Box<ErrorImpl<()>>),358 object_drop_front: unsafe fn(Box<ErrorImpl<()>>),359 object_raw: unsafe fn(&ErrorImpl<()>) -> &(dyn StdError + Send + Sync + 'static),360 object_mut_raw: unsafe fn(&mut ErrorImpl<()>) -> &mut (dyn StdError + Send + Sync + 'static),359 object_ref: unsafe fn(&ErrorImpl<()>) -> &(dyn StdError + Send + Sync + 'static),360 object_mut: unsafe fn(&mut ErrorImpl<()>) -> &mut (dyn StdError + Send + Sync + 'static),361 object_boxed: unsafe fn(Box<ErrorImpl<()>>) -> Box<dyn StdError + Send + Sync + 'static>,362}363364unsafe fn object_drop<E>(e: Box<ErrorImpl<()>>) {
10 unmodified lines
375 let unerased = mem::transmute::<Box<ErrorImpl<()>>, Box<ErrorImpl<ManuallyDrop<E>>>>(e);376 drop(unerased);377}378379unsafe fn object_raw<E>(e: &ErrorImpl<()>) -> &(dyn StdError + Send + Sync + 'static)379unsafe fn object_ref<E>(e: &ErrorImpl<()>) -> &(dyn StdError + Send + Sync + 'static)380where381 E: StdError + Send + Sync + 'static,382{383 &(*(e as *const ErrorImpl<()> as *const ErrorImpl<E>))._error384}385386unsafe fn object_mut_raw<E>(e: &mut ErrorImpl<()>) -> &mut (dyn StdError + Send + Sync + 'static)386unsafe fn object_mut<E>(e: &mut ErrorImpl<()>) -> &mut (dyn StdError + Send + Sync + 'static)387where388 E: StdError + Send + Sync + 'static,389{390 &mut (*(e as *mut ErrorImpl<()> as *mut ErrorImpl<E>))._error
69 unmodified lines
460}461462impl ErrorImpl<()> {463 fn error(&self) -> &(dyn StdError + Send + Sync + 'static) {464 unsafe { &*(self.vtable.object_raw)(self) }464 unsafe { &*(self.vtable.object_ref)(self) }465 }466467 fn error_mut(&mut self) -> &mut (dyn StdError + Send + Sync + 'static) {468 unsafe { &mut *(self.vtable.object_mut_raw)(self) }468 unsafe { &mut *(self.vtable.object_mut)(self) }469 }470471 #[cfg(backtrace)]472 fn backtrace(&self) -> &Backtrace {
128 unmodified lines