diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-12-19 15:26:24 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-12-23 13:23:10 +1100 |
| commit | 757d6f6ef8567ec846a62f16e3691b7555f2545f (patch) | |
| tree | da16dce1d2e7d8f47288f65900ceebfc0aebbfbd /compiler/rustc_hir_analysis/src/structured_errors.rs | |
| parent | 6257f3bf1f8679296eeb69b3578573d3fed78b31 (diff) | |
| download | rust-757d6f6ef8567ec846a62f16e3691b7555f2545f.tar.gz rust-757d6f6ef8567ec846a62f16e3691b7555f2545f.zip | |
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.
Diffstat (limited to 'compiler/rustc_hir_analysis/src/structured_errors.rs')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/structured_errors.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/compiler/rustc_hir_analysis/src/structured_errors.rs b/compiler/rustc_hir_analysis/src/structured_errors.rs index 0b46fce1735..04d04304e70 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors.rs @@ -6,7 +6,7 @@ pub use self::{ missing_cast_for_variadic_arg::*, sized_unsized_cast::*, wrong_number_of_generic_args::*, }; -use rustc_errors::{DiagnosticBuilder, DiagnosticId, ErrorGuaranteed}; +use rustc_errors::{DiagnosticBuilder, DiagnosticId}; use rustc_session::Session; pub trait StructuredDiagnostic<'tcx> { @@ -14,7 +14,7 @@ pub trait StructuredDiagnostic<'tcx> { fn code(&self) -> DiagnosticId; - fn diagnostic(&self) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { + fn diagnostic(&self) -> DiagnosticBuilder<'tcx> { let err = self.diagnostic_common(); if self.session().teach(&self.code()) { @@ -24,19 +24,13 @@ pub trait StructuredDiagnostic<'tcx> { } } - fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>; + fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx>; - fn diagnostic_regular( - &self, - err: DiagnosticBuilder<'tcx, ErrorGuaranteed>, - ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { + fn diagnostic_regular(&self, err: DiagnosticBuilder<'tcx>) -> DiagnosticBuilder<'tcx> { err } - fn diagnostic_extended( - &self, - err: DiagnosticBuilder<'tcx, ErrorGuaranteed>, - ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { + fn diagnostic_extended(&self, err: DiagnosticBuilder<'tcx>) -> DiagnosticBuilder<'tcx> { err } } |
