From 541d7cc65c56402f31335e41075838c0da5fbe01 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 6 Mar 2024 14:00:16 +1100 Subject: Rename `AddToDiagnostic` as `Subdiagnostic`. To match `derive(Subdiagnostic)`. Also rename `add_to_diagnostic{,_with}` as `add_to_diag{,_with}`. --- compiler/rustc_errors/src/diagnostic.rs | 14 +++++++------- compiler/rustc_errors/src/diagnostic_impls.rs | 6 +++--- compiler/rustc_errors/src/lib.rs | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'compiler/rustc_errors') diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 5793cb13e67..ccaf8c7a235 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -170,19 +170,19 @@ impl Into> for DiagArgValue { /// Trait implemented by error types. This should not be implemented manually. Instead, use /// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic]. -#[rustc_diagnostic_item = "AddToDiagnostic"] -pub trait AddToDiagnostic +#[rustc_diagnostic_item = "Subdiagnostic"] +pub trait Subdiagnostic where Self: Sized, { /// Add a subdiagnostic to an existing diagnostic. - fn add_to_diagnostic(self, diag: &mut Diag<'_, G>) { - self.add_to_diagnostic_with(diag, |_, m| m); + fn add_to_diag(self, diag: &mut Diag<'_, G>) { + self.add_to_diag_with(diag, |_, m| m); } /// Add a subdiagnostic to an existing diagnostic where `f` is invoked on every message used /// (to optionally perform eager translation). - fn add_to_diagnostic_with>( + fn add_to_diag_with>( self, diag: &mut Diag<'_, G>, f: F, @@ -1194,9 +1194,9 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { pub fn subdiagnostic( &mut self, dcx: &crate::DiagCtxt, - subdiagnostic: impl AddToDiagnostic, + subdiagnostic: impl Subdiagnostic, ) -> &mut Self { - subdiagnostic.add_to_diagnostic_with(self, |diag, msg| { + subdiagnostic.add_to_diag_with(self, |diag, msg| { let args = diag.args.iter(); let msg = diag.subdiagnostic_message_to_diagnostic_message(msg); dcx.eagerly_translate(msg, args) diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index 5f65f35cc30..f90190797ae 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -1,5 +1,5 @@ use crate::diagnostic::DiagLocation; -use crate::{fluent_generated as fluent, AddToDiagnostic}; +use crate::{fluent_generated as fluent, Subdiagnostic}; use crate::{ Diag, DiagArgValue, DiagCtxt, Diagnostic, EmissionGuarantee, ErrCode, IntoDiagArg, Level, SubdiagMessageOp, @@ -297,8 +297,8 @@ pub struct SingleLabelManySpans { pub spans: Vec, pub label: &'static str, } -impl AddToDiagnostic for SingleLabelManySpans { - fn add_to_diagnostic_with>( +impl Subdiagnostic for SingleLabelManySpans { + fn add_to_diag_with>( self, diag: &mut Diag<'_, G>, _: F, diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index b079de1dde1..99c5bb46d2f 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -37,9 +37,9 @@ extern crate self as rustc_errors; pub use codes::*; pub use diagnostic::{ - AddToDiagnostic, BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, - DiagInner, DiagStyledString, Diagnostic, EmissionGuarantee, FatalAbort, IntoDiagArg, - StringPart, Subdiag, SubdiagMessageOp, + BugAbort, DecorateLint, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, DiagInner, + DiagStyledString, Diagnostic, EmissionGuarantee, FatalAbort, IntoDiagArg, StringPart, Subdiag, + SubdiagMessageOp, Subdiagnostic, }; pub use diagnostic_impls::{ DiagArgFromDisplay, DiagSymbolList, ExpectedLifetimeParameter, IndicateAnonymousLifetime, -- cgit 1.4.1-3-g733a5