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

@ -2,7 +2,7 @@ use std::cmp;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_errors::{DiagnosticBuilder, DiagnosticMessage, MultiSpan};
use rustc_errors::{Diag, DiagnosticMessage, MultiSpan};
use rustc_hir::{HirId, ItemLocalId};
use rustc_session::lint::{
builtin::{self, FORBIDDEN_LINT_GROUPS},
@ -204,7 +204,7 @@ pub fn explain_lint_level_source(
lint: &'static Lint,
level: Level,
src: LintLevelSource,
err: &mut DiagnosticBuilder<'_, ()>,
err: &mut Diag<'_, ()>,
) {
let name = lint.name_lower();
if let Level::Allow = level {
@ -260,8 +260,7 @@ pub fn explain_lint_level_source(
///
/// ## `decorate`
///
/// It is not intended to call `emit`/`cancel` on the `DiagnosticBuilder` passed
/// in the `decorate` callback.
/// It is not intended to call `emit`/`cancel` on the `Diag` passed in the `decorate` callback.
#[track_caller]
pub fn lint_level(
sess: &Session,
@ -270,7 +269,7 @@ pub fn lint_level(
src: LintLevelSource,
span: Option<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
) {
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
// the "real" work.
@ -282,7 +281,7 @@ pub fn lint_level(
src: LintLevelSource,
span: Option<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
decorate: Box<dyn '_ + for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>)>,
decorate: Box<dyn '_ + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>)>,
) {
// Check for future incompatibility lints and issue a stronger warning.
let future_incompatible = lint.future_incompatible;
@ -314,7 +313,7 @@ pub fn lint_level(
//
// We can also not mark the lint expectation as fulfilled here right away, as it
// can still be cancelled in the decorate function. All of this means that we simply
// create a `DiagnosticBuilder` and continue as we would for warnings.
// create a `Diag` and continue as we would for warnings.
rustc_errors::Level::Expect(expect_id)
}
Level::ForceWarn(Some(expect_id)) => rustc_errors::Level::ForceWarning(Some(expect_id)),
@ -322,7 +321,7 @@ pub fn lint_level(
Level::Warn => rustc_errors::Level::Warning,
Level::Deny | Level::Forbid => rustc_errors::Level::Error,
};
let mut err = DiagnosticBuilder::new(sess.dcx(), err_level, "");
let mut err = Diag::new(sess.dcx(), err_level, "");
if let Some(span) = span {
err.span(span);
}

View file

@ -9,7 +9,7 @@ use rustc_attr::{
self as attr, ConstStability, DefaultBodyStability, DeprecatedSince, Deprecation, Stability,
};
use rustc_data_structures::unord::UnordMap;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_errors::{Applicability, Diag};
use rustc_feature::GateIssue;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdMap};
@ -125,7 +125,7 @@ pub fn report_unstable(
}
pub fn deprecation_suggestion(
diag: &mut DiagnosticBuilder<'_, ()>,
diag: &mut Diag<'_, ()>,
kind: &str,
suggestion: Option<Symbol>,
span: Span,

View file

@ -16,7 +16,7 @@ use crate::ty::GenericArgsRef;
use crate::ty::{self, AdtKind, Ty};
use rustc_data_structures::sync::Lrc;
use rustc_errors::{Applicability, DiagnosticBuilder, EmissionGuarantee};
use rustc_errors::{Applicability, Diag, EmissionGuarantee};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_span::def_id::{LocalDefId, CRATE_DEF_ID};
@ -908,7 +908,7 @@ pub enum ObjectSafetyViolationSolution {
}
impl ObjectSafetyViolationSolution {
pub fn add_to<G: EmissionGuarantee>(self, err: &mut DiagnosticBuilder<'_, G>) {
pub fn add_to<G: EmissionGuarantee>(self, err: &mut Diag<'_, G>) {
match self {
ObjectSafetyViolationSolution::None => {}
ObjectSafetyViolationSolution::AddSelfOrMakeSized {

View file

@ -43,9 +43,7 @@ use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, WorkerLocal};
#[cfg(parallel_compiler)]
use rustc_data_structures::sync::{DynSend, DynSync};
use rustc_data_structures::unord::UnordSet;
use rustc_errors::{
DecorateLint, DiagCtxt, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, MultiSpan,
};
use rustc_errors::{DecorateLint, Diag, DiagCtxt, DiagnosticMessage, ErrorGuaranteed, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
@ -2117,7 +2115,7 @@ impl<'tcx> TyCtxt<'tcx> {
hir_id: HirId,
span: impl Into<MultiSpan>,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
) {
let (level, src) = self.lint_level_at_node(lint, hir_id);
lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate);
@ -2147,7 +2145,7 @@ impl<'tcx> TyCtxt<'tcx> {
lint: &'static Lint,
id: HirId,
msg: impl Into<DiagnosticMessage>,
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
decorate: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>),
) {
let (level, src) = self.lint_level_at_node(lint, id);
lint_level(self.sess, lint, level, src, None, msg, decorate);

View file

@ -11,7 +11,7 @@ use crate::ty::{
};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{Applicability, DiagnosticArgValue, DiagnosticBuilder, IntoDiagnosticArg};
use rustc_errors::{Applicability, Diag, DiagnosticArgValue, IntoDiagnosticArg};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
@ -111,7 +111,7 @@ where
pub fn suggest_arbitrary_trait_bound<'tcx>(
tcx: TyCtxt<'tcx>,
generics: &hir::Generics<'_>,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
trait_pred: PolyTraitPredicate<'tcx>,
associated_ty: Option<(&'static str, Ty<'tcx>)>,
) -> bool {
@ -216,7 +216,7 @@ fn suggest_changing_unsized_bound(
pub fn suggest_constraining_type_param(
tcx: TyCtxt<'_>,
generics: &hir::Generics<'_>,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
param_name: &str,
constraint: &str,
def_id: Option<DefId>,
@ -235,7 +235,7 @@ pub fn suggest_constraining_type_param(
pub fn suggest_constraining_type_params<'a>(
tcx: TyCtxt<'_>,
generics: &hir::Generics<'_>,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
param_names_and_constraints: impl Iterator<Item = (&'a str, &'a str, Option<DefId>)>,
span_to_replace: Option<Span>,
) -> bool {

View file

@ -5,8 +5,7 @@ use crate::ty::normalize_erasing_regions::NormalizationError;
use crate::ty::{self, ConstKind, Ty, TyCtxt, TypeVisitableExt};
use rustc_error_messages::DiagnosticMessage;
use rustc_errors::{
DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic,
IntoDiagnosticArg, Level,
Diag, DiagCtxt, DiagnosticArgValue, EmissionGuarantee, IntoDiagnostic, IntoDiagnosticArg, Level,
};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
@ -1262,7 +1261,7 @@ pub enum FnAbiError<'tcx> {
}
impl<'a, 'b, G: EmissionGuarantee> IntoDiagnostic<'a, G> for FnAbiError<'b> {
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> {
match self {
Self::Layout(e) => e.into_diagnostic().into_diagnostic(dcx, level),
Self::AdjustForForeignAbi(call::AdjustForForeignAbiError::Unsupported {

View file

@ -39,7 +39,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::steal::Steal;
use rustc_data_structures::tagged_ptr::CopyTaggedPtr;
use rustc_data_structures::unord::UnordMap;
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, StashKey};
use rustc_errors::{Diag, ErrorGuaranteed, StashKey};
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap, LocalDefIdSet};
@ -845,7 +845,7 @@ impl<'tcx> OpaqueHiddenType<'tcx> {
other: &Self,
opaque_def_id: LocalDefId,
tcx: TyCtxt<'tcx>,
) -> Result<DiagnosticBuilder<'tcx>, ErrorGuaranteed> {
) -> Result<Diag<'tcx>, ErrorGuaranteed> {
if let Some(diag) = tcx
.sess
.dcx()