zkat / miette

Fancy extension for std::error::Error with pretty, detailed diagnostic printing.
https://docs.rs/miette
Apache License 2.0
1.85k stars 106 forks source link

feat(derive): enable more boxed types to be #[diagnostic_source] #338

Closed TheLostLambda closed 4 months ago

TheLostLambda commented 4 months ago

Hello again! Nice and small change this time :)

The #[diagnostic_source] attribute already worked for Box<dyn Diagnostic>, but not for the highly-related Box<dyn Diagnostic + Send> and Box<dyn Diagnostic + Send + Sync> types!

It looks like someone already solved this issue for std::error:Error with a macro_rules! implementation, so I've done the same here to let those new cases compile! Without those Borrow<dyn Diagnostic> impls, you end up with compiler errors coming from inside of the derive macro:

Screenshot from 2024-02-06 20-26-45

Let me know if you have any questions! I'll separately try to sort out those failing tests (unrelated to this change) in another PR :)

TheLostLambda commented 4 months ago

With some luck, #339 should fix the tests failing for everyone — I don't think there was a behavior change, I think the reference strings just got mangled somehow in a commit from three days ago.