about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-02-01 10:13:24 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-02-19 20:23:20 +1100
commitb18f3e11fa9c2d6fb8a6c4807229bebc3608d3ac (patch)
tree733ac87b5dd3c7ba88b0655b0ee3282a2fa02ba3 /compiler/rustc_trait_selection/src/traits/specialize/mod.rs
parent8b21296b5db6d5724d6b8440dcf459fa82fd88b5 (diff)
downloadrust-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_trait_selection/src/traits/specialize/mod.rs')
-rw-r--r--compiler/rustc_trait_selection/src/traits/specialize/mod.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
index e1a49ecf1b6..56bc2f2cf25 100644
--- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs
@@ -20,7 +20,7 @@ use crate::traits::{
     self, coherence, FutureCompatOverlapErrorKind, ObligationCause, ObligationCtxt,
 };
 use rustc_data_structures::fx::FxIndexSet;
-use rustc_errors::{codes::*, DelayDm, Diagnostic};
+use rustc_errors::{codes::*, DelayDm, DiagnosticBuilder, EmissionGuarantee};
 use rustc_hir::def_id::{DefId, LocalDefId};
 use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt};
 use rustc_middle::ty::{GenericArgs, GenericArgsRef};
@@ -395,11 +395,11 @@ fn report_conflicting_impls<'tcx>(
     // Work to be done after we've built the DiagnosticBuilder. We have to define it
     // now because the lint emit methods don't return back the DiagnosticBuilder
     // that's passed in.
-    fn decorate<'tcx>(
+    fn decorate<'tcx, G: EmissionGuarantee>(
         tcx: TyCtxt<'tcx>,
         overlap: &OverlapError<'tcx>,
         impl_span: Span,
-        err: &mut Diagnostic,
+        err: &mut DiagnosticBuilder<'_, G>,
     ) {
         if (overlap.trait_ref, overlap.self_ty).references_error() {
             err.downgrade_to_delayed_bug();