miette icon indicating copy to clipboard operation
miette copied to clipboard

feat!(render): render_report can accept more types

Open TheLostLambda opened this issue 9 months ago • 0 comments

This PR builds on PR #367! Merging this should be equivalent to merging both!

You can now pass a &dyn Diagnostic (as before), or a Report (or &Report, &mut Report, or Box<Report>), or anything else that implements Diagnostic to render_report.

More generally, users can use the AsDiagnostic trait wherever they want to write functions that accept either a Report or Diagnostic — this improves ergonomics in a world where impl Diagnostic for Report is impossible.

BREAKING CHANGE: Because more types can now be passed to render_report, Report::as_ref() can get confused about types, and inference fails. The solution is removing the .as_ref() altogether since Report is now a directly accepted type.

This would also effectively close #366 (for my purposes, at least), since anything accepting AsDiagnostic will work for Report and anything that implements Diagnostic!

BEFORE MERGING: After getting the green light from you, but before merging this, I'll have to properly fill in the documentation for AsDiagnostic! I don't think WOOF and BARK is particularly helpful, but I didn't want to write docs before knowing if you'd be interested in accepting this PR!

TheLostLambda avatar Apr 26 '24 01:04 TheLostLambda