vtable function only works on erased `ErrorImpl`

+ slight reorg
This commit is contained in:
Nathan Whitaker 2022-08-20 13:48:51 -07:00
parent 460de635e0
commit 42d2768d3b
1 changed files with 3 additions and 3 deletions

View File

@ -452,8 +452,6 @@ impl Drop for Report {
}
}
type ErasedErrorImpl = ErrorImpl<()>;
struct ErrorVTable {
object_drop: unsafe fn(Own<ErasedErrorImpl>),
object_ref:
@ -658,8 +656,10 @@ pub(crate) struct ContextError<D, E> {
pub(crate) error: E,
}
type ErasedErrorImpl = ErrorImpl<()>;
// Safety: `ErrorVTable` must be the first field of `ErrorImpl`
unsafe fn vtable<E>(p: NonNull<ErrorImpl<E>>) -> &'static ErrorVTable {
unsafe fn vtable(p: NonNull<ErasedErrorImpl>) -> &'static ErrorVTable {
(p.as_ptr() as *const &'static ErrorVTable).read()
}