Skip to content
Myr

Rename source to object in vtable

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

Since these function pointers have nothing to do with Error::source.

authored by David Tolnay · committed by David Tolnay · parent 8220e0a · 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
60 unmodified lines
61 E: StdError + Send + Sync + 'static,62 {63 unsafe {64 let vtable = &ErrorVTable {65 source: source_raw::<E>,66 source_mut: source_mut_raw::<E>,65 object: object_raw::<E>,66 object_mut: object_mut_raw::<E>,67 };68 let inner = Box::new(ErrorImpl {69 vtable,70 type_id,
296 unmodified lines
367 }368}369370struct ErrorVTable {371 source: unsafe fn(*const ()) -> *const (dyn StdError + Send + Sync + 'static),372 source_mut: unsafe fn(*mut ()) -> *mut (dyn StdError + Send + Sync + 'static),371 object: unsafe fn(*const ()) -> *const (dyn StdError + Send + Sync + 'static),372 object_mut: unsafe fn(*mut ()) -> *mut (dyn StdError + Send + Sync + 'static),373}374375unsafe fn source_raw<E>(e: *const ()) -> *const (dyn StdError + Send + Sync + 'static)375unsafe fn object_raw<E>(e: *const ()) -> *const (dyn StdError + Send + Sync + 'static)376where377 E: StdError + Send + Sync + 'static,378{379 e as *const E380}381382unsafe fn source_mut_raw<E>(e: *mut ()) -> *mut (dyn StdError + Send + Sync + 'static)382unsafe fn object_mut_raw<E>(e: *mut ()) -> *mut (dyn StdError + Send + Sync + 'static)383where384 E: StdError + Send + Sync + 'static,385{386 e as *mut E
32 unmodified lines
419impl<M> StdError for MessageError<M> where M: Display + Debug + 'static {}420421impl ErrorImpl<()> {422 fn error(&self) -> &(dyn StdError + Send + Sync + 'static) {423 unsafe { &*(self.vtable.source)(&self.error) }423 unsafe { &*(self.vtable.object)(&self.error) }424 }425426 fn error_mut(&mut self) -> &mut (dyn StdError + Send + Sync + 'static) {427 unsafe { &mut *(self.vtable.source_mut)(&mut self.error) }427 unsafe { &mut *(self.vtable.object_mut)(&mut self.error) }428 }429}430431/// Iterator of a chain of source errors.
83 unmodified lines