Skip to content

Commit

Permalink
Only need vtable function for a type erased ErrorImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 10, 2021
1 parent bd5e39b commit d1b0c9a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -733,8 +733,7 @@ pub(crate) struct ErrorImpl<E = ()> {

// Reads the vtable out of `p`. This is the same as `p.as_ref().vtable`, but
// avoids converting `p` into a reference.
#[inline]
unsafe fn vtable<E>(p: NonNull<ErrorImpl<E>>) -> &'static ErrorVTable {
unsafe fn vtable(p: NonNull<ErrorImpl>) -> &'static ErrorVTable {
// NOTE: This assumes that `ErrorVTable` is the first field of ErrorImpl.
(p.as_ptr() as *const &'static ErrorVTable).read()
}

0 comments on commit d1b0c9a

Please sign in to comment.