Closed
Description
In our first @rust-lang/wg-diagnostics meeting on zulip we figured that a first start would be to create a new trait
trait AsError {
/// ParseSess, Session or `TyCtxt`
type Session;
fn to_error(self, session: Self::Session) -> DiagnosticBuilder;
fn emit(self) {
self.to_error().emit()
}
}
that is implemented for structs containing all relevant info for a diagnostic, e.g.
struct TypeError {
expected: Ty,
found: Ty,
span: Span,
}
and then the code that currently constructs the diagnostic and emits it would just become
TypeError {
expected,
found,
span: Span,
}.emit();
This issue has been assigned to @jumbatm via this comment.