diff options
| author | bors <bors@rust-lang.org> | 2024-02-20 12:05:09 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-20 12:05:09 +0000 | 
| commit | 29f87ade9d78d233e85ef6ca2d6153d0d4fd38d6 (patch) | |
| tree | 6224d184fc8bb6bb02ef7ef2838d4114169ddb60 /compiler/rustc_hir_analysis | |
| parent | cce6a6e22e715bd74455f2560a956ab920c3a914 (diff) | |
| parent | f6f87798439e2ce7861da761b444fe0978335ed9 (diff) | |
| download | rust-29f87ade9d78d233e85ef6ca2d6153d0d4fd38d6.tar.gz rust-29f87ade9d78d233e85ef6ca2d6153d0d4fd38d6.zip  | |
Auto merge of #120576 - nnethercote:merge-Diagnostic-DiagnosticBuilder, r=davidtwco
Overhaul `Diagnostic` and `DiagnosticBuilder` Implements the first part of https://github.com/rust-lang/compiler-team/issues/722, which moves functionality and use away from `Diagnostic`, onto `DiagnosticBuilder`. Likely follow-ups: - Move things around, because this PR was written to minimize diff size, so some things end up in sub-optimal places. E.g. `DiagnosticBuilder` has impls in both `diagnostic.rs` and `diagnostic_builder.rs`. - Rename `Diagnostic` as `DiagInner` and `DiagnosticBuilder` as `Diag`. r? `@davidtwco`
Diffstat (limited to 'compiler/rustc_hir_analysis')
7 files changed, 32 insertions, 28 deletions
diff --git a/compiler/rustc_hir_analysis/src/astconv/errors.rs b/compiler/rustc_hir_analysis/src/astconv/errors.rs index ad34c31ef8f..214d9602968 100644 --- a/compiler/rustc_hir_analysis/src/astconv/errors.rs +++ b/compiler/rustc_hir_analysis/src/astconv/errors.rs @@ -9,7 +9,7 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::sorted_map::SortedMap; use rustc_data_structures::unord::UnordMap; use rustc_errors::{ - codes::*, pluralize, struct_span_code_err, Applicability, Diagnostic, ErrorGuaranteed, + codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, }; use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; @@ -371,7 +371,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // FIXME(fmease): Heavily adapted from `rustc_hir_typeck::method::suggest`. Deduplicate. fn note_ambiguous_inherent_assoc_type( &self, - err: &mut Diagnostic, + err: &mut DiagnosticBuilder<'_>, candidates: Vec<DefId>, span: Span, ) { @@ -429,7 +429,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let tcx = self.tcx(); let adt_did = self_ty.ty_adt_def().map(|def| def.did()); - let add_def_label = |err: &mut Diagnostic| { + let add_def_label = |err: &mut DiagnosticBuilder<'_>| { if let Some(did) = adt_did { err.span_label( tcx.def_span(did), diff --git a/compiler/rustc_hir_analysis/src/astconv/generics.rs b/compiler/rustc_hir_analysis/src/astconv/generics.rs index 614e5f9d32b..b20326ae5e1 100644 --- a/compiler/rustc_hir_analysis/src/astconv/generics.rs +++ b/compiler/rustc_hir_analysis/src/astconv/generics.rs @@ -6,7 +6,7 @@ use crate::astconv::{ use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs}; use rustc_ast::ast::ParamKindOrd; use rustc_errors::{ - codes::*, struct_span_code_err, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan, + codes::*, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, }; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; @@ -47,7 +47,7 @@ fn generic_arg_mismatch_err( } } - let add_braces_suggestion = |arg: &GenericArg<'_>, err: &mut Diagnostic| { + let add_braces_suggestion = |arg: &GenericArg<'_>, err: &mut DiagnosticBuilder<'_>| { let suggestions = vec