Which converts a Box<ErrorImpl<E>> into the Box<dyn Diagnostic>, hence the resultant object ends up with the empty Diagnostic impl defined above!
This fix moves the _object out of the Box<ErrorImpl<E>> to create a Box<E> before conversion to Box<dyn Diagnostic>, attaching the correct Diagnostic impl for the original error E.
Miri seems happy, and I've actually only added safe code, even though it's in an unsafe function because of .boxed() which I left untouched.
But now that we aren't ever trying to convert ErrorImpl<E>s into trait objects anymore — directly converting Es instead — I've deleted that unused code.
Fixes #369
The culprit was:
https://github.com/zkat/miette/blob/ea4296dacec3b0e4762281d9d115c1bd69ecfac3/src/eyreish/error.rs#L728
In conjunction with:
https://github.com/zkat/miette/blob/ea4296dacec3b0e4762281d9d115c1bd69ecfac3/src/eyreish/error.rs#L531-L537
Which converts a
Box<ErrorImpl<E>>
into theBox<dyn Diagnostic>
, hence the resultant object ends up with the emptyDiagnostic
impl defined above!This fix moves the
_object
out of theBox<ErrorImpl<E>>
to create aBox<E>
before conversion toBox<dyn Diagnostic>
, attaching the correctDiagnostic
impl for the original errorE
.Miri seems happy, and I've actually only added safe code, even though it's in an
unsafe
function because of.boxed()
which I left untouched.As a side note, the only reason converting to
Box<dyn Error>
worked is because of this manual pass-through done here: https://github.com/zkat/miette/blob/ea4296dacec3b0e4762281d9d115c1bd69ecfac3/src/eyreish/error.rs#L719-L726But now that we aren't ever trying to convert
ErrorImpl<E>
s into trait objects anymore — directly convertingE
s instead — I've deleted that unused code.