From 42d2768d3b8acf448273893bfe37a7fdc4e01f91 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker Date: Sat, 20 Aug 2022 13:48:51 -0700 Subject: [PATCH] vtable function only works on erased `ErrorImpl` + slight reorg --- src/eyreish/error.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/eyreish/error.rs b/src/eyreish/error.rs index f54ad68..ef92a0c 100644 --- a/src/eyreish/error.rs +++ b/src/eyreish/error.rs @@ -452,8 +452,6 @@ impl Drop for Report { } } -type ErasedErrorImpl = ErrorImpl<()>; - struct ErrorVTable { object_drop: unsafe fn(Own), object_ref: @@ -658,8 +656,10 @@ pub(crate) struct ContextError { pub(crate) error: E, } +type ErasedErrorImpl = ErrorImpl<()>; + // Safety: `ErrorVTable` must be the first field of `ErrorImpl` -unsafe fn vtable(p: NonNull>) -> &'static ErrorVTable { +unsafe fn vtable(p: NonNull) -> &'static ErrorVTable { (p.as_ptr() as *const &'static ErrorVTable).read() }