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

@ -2,7 +2,7 @@ use crate::fluent_generated as fluent;
use rustc_errors::DiagnosticArgValue;
use rustc_errors::{
error_code, AddToDiagnostic, Applicability, DiagCtxt, Diagnostic, DiagnosticBuilder,
ErrorGuaranteed, IntoDiagnostic, Level, MultiSpan, SubdiagnosticMessage,
IntoDiagnostic, Level, MultiSpan, SubdiagnosticMessage,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{self, Ty};
@ -461,11 +461,7 @@ pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> {
}
impl<'a> IntoDiagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
fn into_diagnostic(
self,
dcx: &'a DiagCtxt,
level: Level,
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'_> {
let mut diag = DiagnosticBuilder::new(
dcx,
level,

View file

@ -54,11 +54,7 @@ pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), Err
visitor.error
}
fn create_e0004(
sess: &Session,
sp: Span,
error_message: String,
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
fn create_e0004(sess: &Session, sp: Span, error_message: String) -> DiagnosticBuilder<'_> {
struct_span_err!(sess, sp, E0004, "{}", &error_message)
}