diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-02-01 10:13:24 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-02-19 20:23:20 +1100 |
| commit | b18f3e11fa9c2d6fb8a6c4807229bebc3608d3ac (patch) | |
| tree | 733ac87b5dd3c7ba88b0655b0ee3282a2fa02ba3 /compiler/rustc_hir_analysis/src/check | |
| parent | 8b21296b5db6d5724d6b8440dcf459fa82fd88b5 (diff) | |
| download | rust-b18f3e11fa9c2d6fb8a6c4807229bebc3608d3ac.tar.gz rust-b18f3e11fa9c2d6fb8a6c4807229bebc3608d3ac.zip | |
Prefer `DiagnosticBuilder` over `Diagnostic` in diagnostic modifiers.
There are lots of functions that modify a diagnostic. This can be via a `&mut Diagnostic` or a `&mut DiagnosticBuilder`, because the latter type wraps the former and impls `DerefMut`. This commit converts all the `&mut Diagnostic` occurrences to `&mut DiagnosticBuilder`. This is a step towards greatly simplifying `Diagnostic`. Some of the relevant function are made generic, because they deal with both errors and warnings. No function bodies are changed, because all the modifier methods are available on both `Diagnostic` and `DiagnosticBuilder`.
Diffstat (limited to 'compiler/rustc_hir_analysis/src/check')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/check.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/mod.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index c3948b1b6bd..b3700013f9c 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1248,7 +1248,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) { fn detect_discriminant_duplicate<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>) { // Helper closure to reduce duplicate code. This gets called everytime we detect a duplicate. // Here `idx` refers to the order of which the discriminant appears, and its index in `vs` - let report = |dis: Discr<'tcx>, idx, err: &mut Diagnostic| { + let report = |dis: Discr<'tcx>, idx, err: &mut DiagnosticBuilder<'_>| { let var = adt.variant(idx); // HIR for the duplicate discriminant let (span, display_discr) = match var.discr { ty::VariantDiscr::Explicit(discr_def_id) => { diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index b9052672a26..36a92a4cf7c 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -78,7 +78,7 @@ use std::num::NonZero; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_errors::ErrorGuaranteed; -use rustc_errors::{pluralize, struct_span_code_err, Diagnostic, DiagnosticBuilder}; +use rustc_errors::{pluralize, struct_span_code_err, DiagnosticBuilder}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::intravisit::Visitor; use rustc_index::bit_set::BitSet; |
