1
Fork 0

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

@ -3,7 +3,7 @@ use std::num::NonZero;
use rustc_ast::token;
use rustc_ast::util::literal::LitError;
use rustc_errors::{
codes::*, DiagCtxt, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed,
codes::*, Diag, DiagCtxt, DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed,
IntoDiagnostic, Level, MultiSpan,
};
use rustc_macros::Diagnostic;
@ -19,8 +19,8 @@ pub struct FeatureGateError {
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for FeatureGateError {
#[track_caller]
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
DiagnosticBuilder::new(dcx, level, self.explain).with_span(self.span).with_code(E0658)
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
Diag::new(dcx, level, self.explain).with_span(self.span).with_code(E0658)
}
}

View file

@ -15,8 +15,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
use rustc_errors::{emitter::SilentEmitter, DiagCtxt};
use rustc_errors::{
fallback_fluent_bundle, DiagnosticBuilder, DiagnosticMessage, EmissionGuarantee, MultiSpan,
StashKey,
fallback_fluent_bundle, Diag, DiagnosticMessage, EmissionGuarantee, MultiSpan, StashKey,
};
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
use rustc_span::edition::Edition;
@ -86,7 +85,7 @@ pub fn feature_err(
feature: Symbol,
span: impl Into<MultiSpan>,
explain: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_> {
) -> Diag<'_> {
feature_err_issue(sess, feature, span, GateIssue::Language, explain)
}
@ -101,7 +100,7 @@ pub fn feature_err_issue(
span: impl Into<MultiSpan>,
issue: GateIssue,
explain: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_> {
) -> Diag<'_> {
let span = span.into();
// Cancel an earlier warning for this same error, if it exists.
@ -158,7 +157,7 @@ pub fn feature_warn_issue(
/// Adds the diagnostics for a feature to an existing error.
pub fn add_feature_diagnostics<G: EmissionGuarantee>(
err: &mut DiagnosticBuilder<'_, G>,
err: &mut Diag<'_, G>,
sess: &Session,
feature: Symbol,
) {
@ -171,7 +170,7 @@ pub fn add_feature_diagnostics<G: EmissionGuarantee>(
/// Almost always, you want to use this for a language feature. If so, prefer
/// `add_feature_diagnostics`.
pub fn add_feature_diagnostics_for_issue<G: EmissionGuarantee>(
err: &mut DiagnosticBuilder<'_, G>,
err: &mut Diag<'_, G>,
sess: &Session,
feature: Symbol,
issue: GateIssue,

View file

@ -22,8 +22,8 @@ use rustc_errors::emitter::{DynEmitter, HumanEmitter, HumanReadableErrorType};
use rustc_errors::json::JsonEmitter;
use rustc_errors::registry::Registry;
use rustc_errors::{
codes::*, fallback_fluent_bundle, DiagCtxt, DiagnosticBuilder, DiagnosticMessage,
ErrorGuaranteed, FatalAbort, FluentBundle, IntoDiagnostic, LazyFallbackBundle, TerminalUrl,
codes::*, fallback_fluent_bundle, Diag, DiagCtxt, DiagnosticMessage, ErrorGuaranteed,
FatalAbort, FluentBundle, IntoDiagnostic, LazyFallbackBundle, TerminalUrl,
};
use rustc_macros::HashStable_Generic;
pub use rustc_span::def_id::StableCrateId;
@ -308,7 +308,7 @@ impl Session {
&'a self,
err: impl IntoDiagnostic<'a>,
feature: Symbol,
) -> DiagnosticBuilder<'a> {
) -> Diag<'a> {
let mut err = self.dcx().create_err(err);
if err.code.is_none() {
err.code(E0658);
@ -1442,10 +1442,7 @@ impl EarlyDiagCtxt {
#[allow(rustc::untranslatable_diagnostic)]
#[allow(rustc::diagnostic_outside_of_impl)]
pub fn early_struct_fatal(
&self,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, FatalAbort> {
pub fn early_struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> Diag<'_, FatalAbort> {
self.dcx.struct_fatal(msg)
}