Fix #369 (Loss of Diagnostic
information when Report
is converted to Box<dyn Diagnostic>
)
#370
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #369
The culprit was:
miette/src/eyreish/error.rs
Line 728 in ea4296d
In conjunction with:
miette/src/eyreish/error.rs
Lines 531 to 537 in ea4296d
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:miette/src/eyreish/error.rs
Lines 719 to 726 in ea4296d
But 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.