Rename DiagnosticBuilder as Diag.

Much better!

Note that this involves renaming (and updating the value of)
`DIAGNOSTIC_BUILDER` in clippy.
This commit is contained in:
Nicholas Nethercote 2024-02-23 10:20:45 +11:00
parent 4e1f9bd528
commit 899cb40809
153 changed files with 1136 additions and 1367 deletions

View file

@ -1,6 +1,6 @@
use rustc_errors::{
codes::*, AddToDiagnostic, DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic,
Level, MultiSpan, SingleLabelManySpans, SubdiagnosticMessageOp,
codes::*, AddToDiagnostic, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level, MultiSpan,
SingleLabelManySpans, SubdiagnosticMessageOp,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{symbol::Ident, Span, Symbol};
@ -448,12 +448,12 @@ pub(crate) struct EnvNotDefinedWithUserMessage {
// Hand-written implementation to support custom user messages.
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for EnvNotDefinedWithUserMessage {
#[track_caller]
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
#[expect(
rustc::untranslatable_diagnostic,
reason = "cannot translate user-provided messages"
)]
let mut diag = DiagnosticBuilder::new(dcx, level, self.msg_from_user.to_string());
let mut diag = Diag::new(dcx, level, self.msg_from_user.to_string());
diag.span(self.span);
diag
}
@ -613,7 +613,7 @@ pub(crate) struct FormatUnusedArg {
impl AddToDiagnostic for FormatUnusedArg {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
self,
diag: &mut DiagnosticBuilder<'_, G>,
diag: &mut Diag<'_, G>,
f: F,
) {
diag.arg("named", self.named);
@ -800,7 +800,7 @@ pub(crate) struct AsmClobberNoReg {
}
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg {
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
// eager translation as `span_labels` takes `AsRef<str>`
let lbl1 = dcx.eagerly_translate_to_string(
crate::fluent_generated::builtin_macros_asm_clobber_abi,
@ -810,14 +810,10 @@ impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for AsmClobberNoReg {
crate::fluent_generated::builtin_macros_asm_clobber_outputs,
[].into_iter(),
);
DiagnosticBuilder::new(
dcx,
level,
crate::fluent_generated::builtin_macros_asm_clobber_no_reg,
)
.with_span(self.spans.clone())
.with_span_labels(self.clobbers, &lbl1)
.with_span_labels(self.spans, &lbl2)
Diag::new(dcx, level, crate::fluent_generated::builtin_macros_asm_clobber_no_reg)
.with_span(self.spans.clone())
.with_span_labels(self.clobbers, &lbl1)
.with_span_labels(self.spans, &lbl2)
}
}

View file

@ -8,7 +8,7 @@ use rustc_ast::{
FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait,
};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Applicability, DiagnosticBuilder, MultiSpan, PResult, SingleLabelManySpans};
use rustc_errors::{Applicability, Diag, MultiSpan, PResult, SingleLabelManySpans};
use rustc_expand::base::{self, *};
use rustc_parse::parser::Recovered;
use rustc_parse_format as parse;
@ -730,7 +730,7 @@ fn report_redundant_format_arguments<'a>(
args: &FormatArguments,
used: &[bool],
placeholders: Vec<(Span, &str)>,
) -> Option<DiagnosticBuilder<'a>> {
) -> Option<Diag<'a>> {
let mut fmt_arg_indices = vec![];
let mut args_spans = vec![];
let mut fmt_spans = vec![];

View file

@ -5,7 +5,7 @@ use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, attr, GenericParamKind};
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, DiagnosticBuilder, Level};
use rustc_errors::{Applicability, Diag, Level};
use rustc_expand::base::*;
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::{ErrorGuaranteed, FileNameDisplayPreference, Span};
@ -410,7 +410,7 @@ fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>)
Some(ast::ItemKind::MacCall(_)) => Level::Warning,
_ => Level::Error,
};
let mut err = DiagnosticBuilder::<()>::new(dcx, level, msg);
let mut err = Diag::<()>::new(dcx, level, msg);
err.span(attr_sp);
if let Some(item) = item {
err.span_label(