1
Fork 0

Give DiagnosticBuilder a default type.

`IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the
most common diagnostic level. It makes sense to do likewise for the
closely-related (and much more widely used) `DiagnosticBuilder` type,
letting us write `DiagnosticBuilder<'a, ErrorGuaranteed>` as just
`DiagnosticBuilder<'a>`. This cuts over 200 lines of code due to many
multi-line things becoming single line things.
This commit is contained in:
Nicholas Nethercote 2023-12-19 15:26:24 +11:00
parent 6257f3bf1f
commit 757d6f6ef8
59 changed files with 250 additions and 454 deletions

View file

@ -1740,9 +1740,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
sp: Span,
mk_diag: M,
actual_ty: Ty<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>
) -> DiagnosticBuilder<'tcx>
where
M: FnOnce(String) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>,
M: FnOnce(String) -> DiagnosticBuilder<'tcx>,
{
let actual_ty = self.resolve_vars_if_possible(actual_ty);
debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty);
@ -1763,7 +1763,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
expected: Ty<'tcx>,
actual: Ty<'tcx>,
err: TypeError<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
) -> DiagnosticBuilder<'tcx> {
self.report_and_explain_type_error(TypeTrace::types(cause, true, expected, actual), err)
}
@ -1773,7 +1773,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
expected: ty::Const<'tcx>,
actual: ty::Const<'tcx>,
err: TypeError<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
) -> DiagnosticBuilder<'tcx> {
self.report_and_explain_type_error(TypeTrace::consts(cause, true, expected, actual), err)
}
}