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,8 +1,7 @@
use hir::GenericParamKind;
use rustc_errors::{
codes::*, AddToDiagnostic, Applicability, DiagnosticBuilder, DiagnosticMessage,
DiagnosticStyledString, EmissionGuarantee, IntoDiagnosticArg, MultiSpan,
SubdiagnosticMessageOp,
codes::*, AddToDiagnostic, Applicability, Diag, DiagnosticMessage, DiagnosticStyledString,
EmissionGuarantee, IntoDiagnosticArg, MultiSpan, SubdiagnosticMessageOp,
};
use rustc_hir as hir;
use rustc_hir::FnRetTy;
@ -228,7 +227,7 @@ pub enum RegionOriginNote<'a> {
impl AddToDiagnostic for RegionOriginNote<'_> {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
self,
diag: &mut DiagnosticBuilder<'_, G>,
diag: &mut Diag<'_, G>,
_f: F,
) {
let mut label_or_note = |span, msg: DiagnosticMessage| {
@ -293,7 +292,7 @@ pub enum LifetimeMismatchLabels {
impl AddToDiagnostic for LifetimeMismatchLabels {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
self,
diag: &mut DiagnosticBuilder<'_, G>,
diag: &mut Diag<'_, G>,
_f: F,
) {
match self {
@ -341,7 +340,7 @@ pub struct AddLifetimeParamsSuggestion<'a> {
impl AddToDiagnostic for AddLifetimeParamsSuggestion<'_> {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
self,
diag: &mut DiagnosticBuilder<'_, G>,
diag: &mut Diag<'_, G>,
_f: F,
) {
let mut mk_suggestion = || {
@ -443,7 +442,7 @@ pub struct IntroducesStaticBecauseUnmetLifetimeReq {
impl AddToDiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
mut self,
diag: &mut DiagnosticBuilder<'_, G>,
diag: &mut Diag<'_, G>,
_f: F,
) {
self.unmet_requirements
@ -762,7 +761,7 @@ pub struct ConsiderBorrowingParamHelp {
impl AddToDiagnostic for ConsiderBorrowingParamHelp {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
self,
diag: &mut DiagnosticBuilder<'_, G>,
diag: &mut Diag<'_, G>,
f: F,
) {
let mut type_param_span: MultiSpan = self.spans.clone().into();
@ -807,7 +806,7 @@ pub struct DynTraitConstraintSuggestion {
impl AddToDiagnostic for DynTraitConstraintSuggestion {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
self,
diag: &mut DiagnosticBuilder<'_, G>,
diag: &mut Diag<'_, G>,
f: F,
) {
let mut multi_span: MultiSpan = vec![self.span].into();
@ -854,7 +853,7 @@ pub struct ReqIntroducedLocations {
impl AddToDiagnostic for ReqIntroducedLocations {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
mut self,
diag: &mut DiagnosticBuilder<'_, G>,
diag: &mut Diag<'_, G>,
f: F,
) {
for sp in self.spans {
@ -877,7 +876,7 @@ pub struct MoreTargeted {
impl AddToDiagnostic for MoreTargeted {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
self,
diag: &mut DiagnosticBuilder<'_, G>,
diag: &mut Diag<'_, G>,
_f: F,
) {
diag.code(E0772);
@ -1300,7 +1299,7 @@ pub struct SuggestTuplePatternMany {
impl AddToDiagnostic for SuggestTuplePatternMany {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
self,
diag: &mut DiagnosticBuilder<'_, G>,
diag: &mut Diag<'_, G>,
f: F,
) {
diag.arg("path", self.path);

View file

@ -1,8 +1,7 @@
use crate::fluent_generated as fluent;
use crate::infer::error_reporting::nice_region_error::find_anon_type;
use rustc_errors::{
AddToDiagnostic, DiagnosticBuilder, EmissionGuarantee, IntoDiagnosticArg,
SubdiagnosticMessageOp,
AddToDiagnostic, Diag, EmissionGuarantee, IntoDiagnosticArg, SubdiagnosticMessageOp,
};
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::{symbol::kw, Span};
@ -165,7 +164,7 @@ impl RegionExplanation<'_> {
impl AddToDiagnostic for RegionExplanation<'_> {
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
self,
diag: &mut DiagnosticBuilder<'_, G>,
diag: &mut Diag<'_, G>,
f: F,
) {
diag.arg("pref_kind", self.prefix);

View file

@ -60,7 +60,7 @@ use crate::traits::{
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_errors::{
codes::*, pluralize, struct_span_code_err, Applicability, DiagCtxt, DiagnosticBuilder,
codes::*, pluralize, struct_span_code_err, Applicability, Diag, DiagCtxt,
DiagnosticStyledString, ErrorGuaranteed, IntoDiagnosticArg,
};
use rustc_hir as hir;
@ -158,7 +158,7 @@ impl<'tcx> Deref for TypeErrCtxt<'_, 'tcx> {
pub(super) fn note_and_explain_region<'tcx>(
tcx: TyCtxt<'tcx>,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
prefix: &str,
region: ty::Region<'tcx>,
suffix: &str,
@ -183,7 +183,7 @@ pub(super) fn note_and_explain_region<'tcx>(
fn explain_free_region<'tcx>(
tcx: TyCtxt<'tcx>,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
prefix: &str,
region: ty::Region<'tcx>,
suffix: &str,
@ -265,7 +265,7 @@ fn msg_span_from_named_region<'tcx>(
}
fn emit_msg_span(
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
prefix: &str,
description: String,
span: Option<Span>,
@ -281,7 +281,7 @@ fn emit_msg_span(
}
fn label_msg_span(
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
prefix: &str,
description: String,
span: Option<Span>,
@ -303,7 +303,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
hidden_ty: Ty<'tcx>,
hidden_region: ty::Region<'tcx>,
opaque_ty_key: ty::OpaqueTypeKey<'tcx>,
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
let mut err = tcx.dcx().create_err(errors::OpaqueCapturesLifetime {
span,
opaque_ty: Ty::new_opaque(tcx, opaque_ty_key.def_id.to_def_id(), opaque_ty_key.args),
@ -582,11 +582,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
}
/// Adds a note if the types come from similarly named crates
fn check_and_note_conflicting_crates(
&self,
err: &mut DiagnosticBuilder<'_>,
terr: TypeError<'tcx>,
) {
fn check_and_note_conflicting_crates(&self, err: &mut Diag<'_>, terr: TypeError<'tcx>) {
use hir::def_id::CrateNum;
use rustc_hir::definitions::DisambiguatedDefPathData;
use ty::print::Printer;
@ -660,7 +656,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
}
}
let report_path_match = |err: &mut DiagnosticBuilder<'_>, did1: DefId, did2: DefId| {
let report_path_match = |err: &mut Diag<'_>, did1: DefId, did2: DefId| {
// Only report definitions from different crates. If both definitions
// are from a local module we could have false positives, e.g.
// let _ = [{struct Foo; Foo}, {struct Foo; Foo}];
@ -710,7 +706,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
fn note_error_origin(
&self,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
cause: &ObligationCause<'tcx>,
exp_found: Option<ty::error::ExpectedFound<Ty<'tcx>>>,
terr: TypeError<'tcx>,
@ -1544,7 +1540,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
)]
pub fn note_type_err(
&self,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
cause: &ObligationCause<'tcx>,
secondary_span: Option<(Span, Cow<'static, str>)>,
mut values: Option<ValuePairs<'tcx>>,
@ -1591,14 +1587,14 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
types_visitor
}
fn report(&self, err: &mut DiagnosticBuilder<'_>) {
fn report(&self, err: &mut Diag<'_>) {
self.add_labels_for_types(err, "expected", &self.expected);
self.add_labels_for_types(err, "found", &self.found);
}
fn add_labels_for_types(
&self,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
target: &str,
types: &FxIndexMap<TyCategory, FxIndexSet<Span>>,
) {
@ -1809,16 +1805,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
// If two types mismatch but have similar names, mention that specifically.
TypeError::Sorts(values) if let Some(s) = similarity(values) => {
let diagnose_primitive =
|prim: Ty<'tcx>,
shadow: Ty<'tcx>,
defid: DefId,
diagnostic: &mut DiagnosticBuilder<'_>| {
|prim: Ty<'tcx>, shadow: Ty<'tcx>, defid: DefId, diag: &mut Diag<'_>| {
let name = shadow.sort_string(self.tcx);
diagnostic.note(format!(
"{prim} and {name} have similar names, but are actually distinct types"
));
diagnostic
.note(format!("{prim} is a primitive defined by the language"));
diag.note(format!(
"{prim} and {name} have similar names, but are actually distinct types"
));
diag.note(format!("{prim} is a primitive defined by the language"));
let def_span = self.tcx.def_span(defid);
let msg = if defid.is_local() {
format!("{name} is defined in the current crate")
@ -1826,20 +1818,20 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
let crate_name = self.tcx.crate_name(defid.krate);
format!("{name} is defined in crate `{crate_name}`")
};
diagnostic.span_note(def_span, msg);
diag.span_note(def_span, msg);
};
let diagnose_adts =
|expected_adt: ty::AdtDef<'tcx>,
found_adt: ty::AdtDef<'tcx>,
diagnostic: &mut DiagnosticBuilder<'_>| {
diag: &mut Diag<'_>| {
let found_name = values.found.sort_string(self.tcx);
let expected_name = values.expected.sort_string(self.tcx);
let found_defid = found_adt.did();
let expected_defid = expected_adt.did();
diagnostic.note(format!("{found_name} and {expected_name} have similar names, but are actually distinct types"));
diag.note(format!("{found_name} and {expected_name} have similar names, but are actually distinct types"));
for (defid, name) in
[(found_defid, found_name), (expected_defid, expected_name)]
{
@ -1861,7 +1853,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
let crate_name = self.tcx.crate_name(defid.krate);
format!("{name} is defined in crate `{crate_name}`")
};
diagnostic.span_note(def_span, msg);
diag.span_note(def_span, msg);
}
};
@ -2180,7 +2172,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
&self,
trace: TypeTrace<'tcx>,
terr: TypeError<'tcx>,
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr);
let span = trace.cause.span();
@ -2328,7 +2320,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
origin: Option<SubregionOrigin<'tcx>>,
bound_kind: GenericKind<'tcx>,
sub: Region<'tcx>,
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
if let Some(SubregionOrigin::CompareImplItemObligation {
span,
impl_item_def_id,
@ -2741,10 +2733,7 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
}
impl<'tcx> InferCtxt<'tcx> {
fn report_inference_failure(
&self,
var_origin: RegionVariableOrigin,
) -> DiagnosticBuilder<'tcx> {
fn report_inference_failure(&self, var_origin: RegionVariableOrigin) -> Diag<'tcx> {
let br_string = |br: ty::BoundRegionKind| {
let mut s = match br {
ty::BrNamed(_, name) => name.to_string(),

View file

@ -5,7 +5,7 @@ use crate::errors::{
use crate::infer::error_reporting::TypeErrCtxt;
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::InferCtxt;
use rustc_errors::{codes::*, DiagnosticBuilder, IntoDiagnosticArg};
use rustc_errors::{codes::*, Diag, IntoDiagnosticArg};
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_hir::def::{CtorOf, DefKind, Namespace};
@ -371,7 +371,7 @@ impl<'tcx> InferCtxt<'tcx> {
span: Span,
arg_data: InferenceDiagnosticsData,
error_code: TypeAnnotationNeeded,
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
let source_kind = "other";
let source_name = "";
let failure_span = None;
@ -419,7 +419,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
arg: GenericArg<'tcx>,
error_code: TypeAnnotationNeeded,
should_label_span: bool,
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
let arg = self.resolve_vars_if_possible(arg);
let arg_data = self.extract_inference_diagnostics_data(arg, None);

View file

@ -12,7 +12,7 @@ use crate::infer::SubregionOrigin;
use crate::infer::TyCtxt;
use rustc_errors::AddToDiagnostic;
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
use rustc_errors::{Diag, ErrorGuaranteed};
use rustc_hir::Ty;
use rustc_middle::ty::Region;
@ -142,7 +142,7 @@ pub fn suggest_adding_lifetime_params<'tcx>(
sub: Region<'tcx>,
ty_sup: &'tcx Ty<'_>,
ty_sub: &'tcx Ty<'_>,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
) {
let suggestion = AddLifetimeParamsSuggestion { tcx, sub, ty_sup, ty_sub, add_note: false };
suggestion.add_to_diagnostic(err);

View file

@ -1,7 +1,7 @@
use crate::infer::error_reporting::TypeErrCtxt;
use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::lexical_region_resolve::RegionResolutionError::*;
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
use rustc_errors::{Diag, ErrorGuaranteed};
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::Span;
@ -53,7 +53,7 @@ impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx> {
self.cx.tcx
}
pub fn try_report_from_nll(&self) -> Option<DiagnosticBuilder<'tcx>> {
pub fn try_report_from_nll(&self) -> Option<Diag<'tcx>> {
// Due to the improved diagnostics returned by the MIR borrow checker, only a subset of
// the nice region errors are required when running under the MIR borrow checker.
self.try_report_named_anon_conflict()

View file

@ -5,14 +5,14 @@ use crate::{
errors::ExplicitLifetimeRequired,
infer::error_reporting::nice_region_error::find_anon_type::find_anon_type,
};
use rustc_errors::DiagnosticBuilder;
use rustc_errors::Diag;
use rustc_middle::ty;
use rustc_span::symbol::kw;
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// When given a `ConcreteFailure` for a function with parameters containing a named region and
/// an anonymous region, emit an descriptive diagnostic error.
pub(super) fn try_report_named_anon_conflict(&self) -> Option<DiagnosticBuilder<'tcx>> {
pub(super) fn try_report_named_anon_conflict(&self) -> Option<Diag<'tcx>> {
let (span, sub, sup) = self.regions()?;
debug!(

View file

@ -8,7 +8,7 @@ use crate::infer::ValuePairs;
use crate::infer::{SubregionOrigin, TypeTrace};
use crate::traits::{ObligationCause, ObligationCauseCode};
use rustc_data_structures::intern::Interned;
use rustc_errors::{DiagnosticBuilder, IntoDiagnosticArg};
use rustc_errors::{Diag, IntoDiagnosticArg};
use rustc_hir::def::Namespace;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::error::ExpectedFound;
@ -57,7 +57,7 @@ where
impl<'tcx> NiceRegionError<'_, 'tcx> {
/// When given a `ConcreteFailure` for a function with arguments containing a named region and
/// an anonymous region, emit a descriptive diagnostic error.
pub(super) fn try_report_placeholder_conflict(&self) -> Option<DiagnosticBuilder<'tcx>> {
pub(super) fn try_report_placeholder_conflict(&self) -> Option<Diag<'tcx>> {
match &self.error {
///////////////////////////////////////////////////////////////////////////
// NB. The ordering of cases in this match is very
@ -193,7 +193,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
sub_placeholder: Option<Region<'tcx>>,
sup_placeholder: Option<Region<'tcx>>,
value_pairs: &ValuePairs<'tcx>,
) -> Option<DiagnosticBuilder<'tcx>> {
) -> Option<Diag<'tcx>> {
let (expected_args, found_args, trait_def_id) = match value_pairs {
ValuePairs::PolyTraitRefs(ExpectedFound { expected, found })
if expected.def_id() == found.def_id() =>
@ -236,7 +236,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
trait_def_id: DefId,
expected_args: GenericArgsRef<'tcx>,
actual_args: GenericArgsRef<'tcx>,
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
let span = cause.span();
let (leading_ellipsis, satisfy_span, where_span, dup_span, def_id) =

View file

@ -5,12 +5,12 @@ use crate::{
},
};
use rustc_data_structures::intern::Interned;
use rustc_errors::DiagnosticBuilder;
use rustc_errors::Diag;
use rustc_middle::ty::{self, RePlaceholder, Region};
impl<'tcx> NiceRegionError<'_, 'tcx> {
/// Emitted wwhen given a `ConcreteFailure` when relating two placeholders.
pub(super) fn try_report_placeholder_relation(&self) -> Option<DiagnosticBuilder<'tcx>> {
pub(super) fn try_report_placeholder_relation(&self) -> Option<Diag<'tcx>> {
match &self.error {
Some(RegionResolutionError::ConcreteFailure(
SubregionOrigin::RelateRegionParamBound(span),

View file

@ -9,7 +9,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::{SubregionOrigin, TypeTrace};
use crate::traits::{ObligationCauseCode, UnifyReceiverContext};
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{AddToDiagnostic, Applicability, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
use rustc_errors::{AddToDiagnostic, Applicability, Diag, ErrorGuaranteed, MultiSpan};
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::{walk_ty, Visitor};
use rustc_hir::{
@ -261,7 +261,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
pub fn suggest_new_region_bound(
tcx: TyCtxt<'_>,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
fn_returns: Vec<&rustc_hir::Ty<'_>>,
lifetime_name: String,
arg: Option<String>,
@ -488,7 +488,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// `'static` obligation. Suggest relaxing that implicit bound.
fn find_impl_on_dyn_trait(
&self,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
ty: Ty<'_>,
ctxt: &UnifyReceiverContext<'tcx>,
) -> bool {
@ -521,7 +521,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
fn suggest_constrain_dyn_trait_in_impl(
&self,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
found_dids: &FxIndexSet<DefId>,
ident: Ident,
self_ty: &hir::Ty<'_>,

View file

@ -5,7 +5,7 @@ use crate::errors::{
use crate::fluent_generated as fluent;
use crate::infer::error_reporting::{note_and_explain_region, TypeErrCtxt};
use crate::infer::{self, SubregionOrigin};
use rustc_errors::{AddToDiagnostic, DiagnosticBuilder};
use rustc_errors::{AddToDiagnostic, Diag};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::traits::ObligationCauseCode;
use rustc_middle::ty::error::TypeError;
@ -15,11 +15,7 @@ use rustc_span::symbol::kw;
use super::ObligationCauseAsDiagArg;
impl<'tcx> TypeErrCtxt<'_, 'tcx> {
pub(super) fn note_region_origin(
&self,
err: &mut DiagnosticBuilder<'_>,
origin: &SubregionOrigin<'tcx>,
) {
pub(super) fn note_region_origin(&self, err: &mut Diag<'_>, origin: &SubregionOrigin<'tcx>) {
match *origin {
infer::Subtype(ref trace) => RegionOriginNote::WithRequirement {
span: trace.cause.span,
@ -82,7 +78,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
origin: SubregionOrigin<'tcx>,
sub: Region<'tcx>,
sup: Region<'tcx>,
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
let mut err = match origin {
infer::Subtype(box trace) => {
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
@ -294,7 +290,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
&self,
trait_item_def_id: DefId,
impl_item_def_id: LocalDefId,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
) {
// FIXME(compiler-errors): Right now this is only being used for region
// predicate mismatches. Ideally, we'd use it for *all* predicate mismatches,
@ -354,7 +350,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
placeholder_origin: SubregionOrigin<'tcx>,
sub: Region<'tcx>,
sup: Region<'tcx>,
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
// I can't think how to do better than this right now. -nikomatsakis
debug!(?placeholder_origin, ?sub, ?sup, "report_placeholder_failure");
match placeholder_origin {

View file

@ -1,6 +1,6 @@
use super::TypeErrCtxt;
use rustc_errors::Applicability::{MachineApplicable, MaybeIncorrect};
use rustc_errors::{pluralize, DiagnosticBuilder, MultiSpan};
use rustc_errors::{pluralize, Diag, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_middle::traits::ObligationCauseCode;
@ -15,7 +15,7 @@ use rustc_span::{def_id::DefId, sym, BytePos, Span, Symbol};
impl<'tcx> TypeErrCtxt<'_, 'tcx> {
pub fn note_and_explain_type_err(
&self,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
err: TypeError<'tcx>,
cause: &ObligationCause<'tcx>,
sp: Span,
@ -522,7 +522,7 @@ impl<T> Trait<T> for X {
fn suggest_constraint(
&self,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
msg: impl Fn() -> String,
body_owner_def_id: DefId,
proj_ty: &ty::AliasTy<'tcx>,
@ -595,7 +595,7 @@ impl<T> Trait<T> for X {
/// fn that returns the type.
fn expected_projection(
&self,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
proj_ty: &ty::AliasTy<'tcx>,
values: ExpectedFound<Ty<'tcx>>,
body_owner_def_id: DefId,
@ -705,7 +705,7 @@ fn foo(&self) -> Self::T { String::new() }
/// a return type. This can occur when dealing with `TryStream` (#71035).
fn suggest_constraining_opaque_associated_type(
&self,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
msg: impl Fn() -> String,
proj_ty: &ty::AliasTy<'tcx>,
ty: Ty<'tcx>,
@ -740,7 +740,7 @@ fn foo(&self) -> Self::T { String::new() }
fn point_at_methods_that_satisfy_associated_type(
&self,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
assoc_container_id: DefId,
current_method_ident: Option<Symbol>,
proj_ty_item_def_id: DefId,
@ -798,7 +798,7 @@ fn foo(&self) -> Self::T { String::new() }
fn point_at_associated_type(
&self,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
body_owner_def_id: DefId,
found: Ty<'tcx>,
) -> bool {
@ -879,7 +879,7 @@ fn foo(&self) -> Self::T { String::new() }
/// type is defined on a supertrait of the one present in the bounds.
fn constrain_generic_bound_associated_type_structured_suggestion(
&self,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
trait_ref: &ty::TraitRef<'tcx>,
bounds: hir::GenericBounds<'_>,
assoc: ty::AssocItem,
@ -916,7 +916,7 @@ fn foo(&self) -> Self::T { String::new() }
/// associated type to a given type `ty`.
fn constrain_associated_type_structured_suggestion(
&self,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
span: Span,
assoc: ty::AssocItem,
assoc_args: &[ty::GenericArg<'tcx>],

View file

@ -1,7 +1,7 @@
use hir::def::CtorKind;
use hir::intravisit::{walk_expr, walk_stmt, Visitor};
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_errors::{Applicability, Diag};
use rustc_hir as hir;
use rustc_middle::traits::{
IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
@ -76,7 +76,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
pub(super) fn suggest_boxing_for_return_impl_trait(
&self,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
return_sp: Span,
arm_spans: impl Iterator<Item = Span>,
) {
@ -100,7 +100,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
&self,
cause: &ObligationCause<'tcx>,
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
) {
// Heavily inspired by `FnCtxt::suggest_compatible_variants`, with
// some modifications due to that being in typeck and this being in infer.
@ -177,7 +177,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
cause: &ObligationCause<'tcx>,
exp_span: Span,
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
) {
debug!(
"suggest_await_on_expect_found: exp_span={:?}, expected_ty={:?}, found_ty={:?}",
@ -258,7 +258,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
&self,
cause: &ObligationCause<'tcx>,
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
) {
debug!(
"suggest_accessing_field_where_appropriate(cause={:?}, exp_found={:?})",
@ -298,7 +298,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
cause: &ObligationCause<'tcx>,
span: Span,
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
) {
debug!("suggest_function_pointers(cause={:?}, exp_found={:?})", cause, exp_found);
let ty::error::ExpectedFound { expected, found } = exp_found;
@ -532,7 +532,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
span: Span,
hir: hir::Node<'_>,
exp_found: &ty::error::ExpectedFound<ty::PolyTraitRef<'tcx>>,
diag: &mut DiagnosticBuilder<'_>,
diag: &mut Diag<'_>,
) {
// 0. Extract fn_decl from hir
let hir::Node::Expr(hir::Expr {
@ -818,7 +818,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
&self,
blk: &'tcx hir::Block<'tcx>,
expected_ty: Ty<'tcx>,
err: &mut DiagnosticBuilder<'_>,
err: &mut Diag<'_>,
) -> bool {
let diag = self.consider_returning_binding_diag(blk, expected_ty);
match diag {

View file

@ -23,7 +23,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::undo_log::Rollback;
use rustc_data_structures::unify as ut;
use rustc_errors::{DiagCtxt, DiagnosticBuilder, ErrorGuaranteed};
use rustc_errors::{Diag, DiagCtxt, ErrorGuaranteed};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_middle::infer::unify_key::ConstVariableValue;
@ -1767,9 +1767,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
sp: Span,
mk_diag: M,
actual_ty: Ty<'tcx>,
) -> DiagnosticBuilder<'tcx>
) -> Diag<'tcx>
where
M: FnOnce(String) -> DiagnosticBuilder<'tcx>,
M: FnOnce(String) -> Diag<'tcx>,
{
let actual_ty = self.resolve_vars_if_possible(actual_ty);
debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty);
@ -1790,7 +1790,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
expected: Ty<'tcx>,
actual: Ty<'tcx>,
err: TypeError<'tcx>,
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
self.report_and_explain_type_error(TypeTrace::types(cause, true, expected, actual), err)
}
@ -1800,7 +1800,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
expected: ty::Const<'tcx>,
actual: ty::Const<'tcx>,
err: TypeError<'tcx>,
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
self.report_and_explain_type_error(TypeTrace::consts(cause, true, expected, actual), err)
}
}

View file

@ -2,7 +2,7 @@ use super::ObjectSafetyViolation;
use crate::infer::InferCtxt;
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{codes::*, struct_span_code_err, Applicability, DiagnosticBuilder, MultiSpan};
use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::ty::print::with_no_trimmed_paths;
@ -18,7 +18,7 @@ impl<'tcx> InferCtxt<'tcx> {
impl_item_def_id: LocalDefId,
trait_item_def_id: DefId,
requirement: &dyn fmt::Display,
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
let mut err = struct_span_code_err!(
self.tcx.dcx(),
error_span,
@ -45,7 +45,7 @@ pub fn report_object_safety_error<'tcx>(
hir_id: Option<hir::HirId>,
trait_def_id: DefId,
violations: &[ObjectSafetyViolation],
) -> DiagnosticBuilder<'tcx> {
) -> Diag<'tcx> {
let trait_str = tcx.def_path_str(trait_def_id);
let trait_span = tcx.hir().get_if_local(trait_def_id).and_then(|node| match node {
hir::Node::Item(item) => Some(item.ident.span),