I am dealing with the tracing crate, which at some point gives me an Box<dyn Error> and I noticed this type does not implement Error.
I found that the way the standard library is written, Box<T> where T: Error only implements Error when T: Sized. Is this an oversight or is this intentional? How do I change the Box<dyn Error> into an error regardless, that I can return using the anyhow crate?
In the standard library, this is the relevant code (link):
@mbrubeck Is there a workaround for this since I would like to return an Error? Perhaps file an issue at tracing to have them add a Sized specifier on their return type?
dyn Error is a fundamentally unsized type, so they would have to change to some completely different error type.
This could be reasonable feature request. Using Box<dyn Error> in a library can be bad for interop, specifically because of this missing Error impl. However, it's a breaking change, so it would need a major version bump in the tracing-subscriber crate.
For now, it looks like the anyhow! macro can convert from Box<dyn Error> to anyhow::Error: