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:
parent
4e1f9bd528
commit
899cb40809
153 changed files with 1136 additions and 1367 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::fluent_generated as fluent;
|
||||
use rustc_errors::{
|
||||
codes::*, AddToDiagnostic, Applicability, DiagCtxt, DiagnosticBuilder, EmissionGuarantee,
|
||||
IntoDiagnostic, Level, SubdiagnosticMessageOp,
|
||||
codes::*, AddToDiagnostic, Applicability, Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic,
|
||||
Level, SubdiagnosticMessageOp,
|
||||
};
|
||||
use rustc_macros::Diagnostic;
|
||||
use rustc_middle::ty::{self, ClosureKind, PolyTraitRef, Ty};
|
||||
|
@ -59,9 +59,8 @@ pub struct NegativePositiveConflict<'tcx> {
|
|||
|
||||
impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for NegativePositiveConflict<'_> {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> {
|
||||
let mut diag =
|
||||
DiagnosticBuilder::new(dcx, level, fluent::trait_selection_negative_positive_conflict);
|
||||
fn into_diagnostic(self, dcx: &DiagCtxt, level: Level) -> Diag<'_, G> {
|
||||
let mut diag = Diag::new(dcx, level, fluent::trait_selection_negative_positive_conflict);
|
||||
diag.arg("trait_desc", self.trait_desc.print_only_trait_path().to_string());
|
||||
diag.arg("self_desc", self.self_ty.map_or_else(|| "none".to_string(), |ty| ty.to_string()));
|
||||
diag.span(self.impl_span);
|
||||
|
@ -104,7 +103,7 @@ pub enum AdjustSignatureBorrow {
|
|||
impl AddToDiagnostic for AdjustSignatureBorrow {
|
||||
fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagnosticMessageOp<G>>(
|
||||
self,
|
||||
diag: &mut DiagnosticBuilder<'_, G>,
|
||||
diag: &mut Diag<'_, G>,
|
||||
_f: F,
|
||||
) {
|
||||
match self {
|
||||
|
|
|
@ -18,7 +18,7 @@ use crate::traits::{
|
|||
Obligation, ObligationCause, PredicateObligation, PredicateObligations, SelectionContext,
|
||||
};
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_errors::{DiagnosticBuilder, EmissionGuarantee};
|
||||
use rustc_errors::{Diag, EmissionGuarantee};
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, TyCtxtInferExt};
|
||||
|
@ -58,7 +58,7 @@ pub struct OverlapResult<'tcx> {
|
|||
pub involves_placeholder: bool,
|
||||
}
|
||||
|
||||
pub fn add_placeholder_note<G: EmissionGuarantee>(err: &mut DiagnosticBuilder<'_, G>) {
|
||||
pub fn add_placeholder_note<G: EmissionGuarantee>(err: &mut Diag<'_, G>) {
|
||||
err.note(
|
||||
"this behavior recently changed as a result of a bug fix; \
|
||||
see rust-lang/rust#56105 for details",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use crate::infer::InferCtxt;
|
||||
use crate::traits::{Obligation, ObligationCause, ObligationCtxt};
|
||||
use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, Diag};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::Node;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
|
@ -88,7 +88,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
found_args: Vec<ArgKind>,
|
||||
is_closure: bool,
|
||||
closure_arg_span: Option<Span>,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
) -> Diag<'tcx> {
|
||||
let kind = if is_closure { "closure" } else { "function" };
|
||||
|
||||
let args_str = |arguments: &[ArgKind], other: &[ArgKind]| {
|
||||
|
|
|
@ -13,8 +13,8 @@ use hir::def::CtorOf;
|
|||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::{
|
||||
codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, EmissionGuarantee,
|
||||
MultiSpan, Style, SuggestionStyle,
|
||||
codes::*, pluralize, struct_span_code_err, Applicability, Diag, EmissionGuarantee, MultiSpan,
|
||||
Style, SuggestionStyle,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
|
@ -121,7 +121,7 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>(
|
|||
item_id: LocalDefId,
|
||||
hir_generics: &hir::Generics<'tcx>,
|
||||
msg: &str,
|
||||
err: &mut DiagnosticBuilder<'_, G>,
|
||||
err: &mut Diag<'_, G>,
|
||||
fn_sig: Option<&hir::FnSig<'_>>,
|
||||
projection: Option<&ty::AliasTy<'_>>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
|
@ -240,7 +240,7 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>(
|
|||
impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
fn suggest_restricting_param_bound(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
associated_ty: Option<(&'static str, Ty<'tcx>)>,
|
||||
mut body_id: LocalDefId,
|
||||
|
@ -450,7 +450,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn suggest_dereferences(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) -> bool {
|
||||
let mut code = obligation.cause.code();
|
||||
|
@ -743,23 +743,22 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn get_closure_name(
|
||||
&self,
|
||||
def_id: DefId,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
msg: Cow<'static, str>,
|
||||
) -> Option<Symbol> {
|
||||
let get_name =
|
||||
|err: &mut DiagnosticBuilder<'_>, kind: &hir::PatKind<'_>| -> Option<Symbol> {
|
||||
// Get the local name of this closure. This can be inaccurate because
|
||||
// of the possibility of reassignment, but this should be good enough.
|
||||
match &kind {
|
||||
hir::PatKind::Binding(hir::BindingAnnotation::NONE, _, ident, None) => {
|
||||
Some(ident.name)
|
||||
}
|
||||
_ => {
|
||||
err.note(msg);
|
||||
None
|
||||
}
|
||||
let get_name = |err: &mut Diag<'_>, kind: &hir::PatKind<'_>| -> Option<Symbol> {
|
||||
// Get the local name of this closure. This can be inaccurate because
|
||||
// of the possibility of reassignment, but this should be good enough.
|
||||
match &kind {
|
||||
hir::PatKind::Binding(hir::BindingAnnotation::NONE, _, ident, None) => {
|
||||
Some(ident.name)
|
||||
}
|
||||
};
|
||||
_ => {
|
||||
err.note(msg);
|
||||
None
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let hir_id = self.tcx.local_def_id_to_hir_id(def_id.as_local()?);
|
||||
match self.tcx.parent_hir_node(hir_id) {
|
||||
|
@ -779,7 +778,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn suggest_fn_call(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) -> bool {
|
||||
// It doesn't make sense to make this suggestion outside of typeck...
|
||||
|
@ -895,7 +894,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn check_for_binding_assigned_block_without_tail_expression(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) {
|
||||
let mut span = obligation.cause.span;
|
||||
|
@ -972,7 +971,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn suggest_add_clone_to_arg(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) -> bool {
|
||||
let self_ty = self.resolve_vars_if_possible(trait_pred.self_ty());
|
||||
|
@ -1157,7 +1156,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn suggest_add_reference_to_arg(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
poly_trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
has_custom_message: bool,
|
||||
) -> bool {
|
||||
|
@ -1378,7 +1377,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
// Suggest borrowing the type
|
||||
fn suggest_borrowing_for_object_cast(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
self_ty: Ty<'tcx>,
|
||||
target_ty: Ty<'tcx>,
|
||||
|
@ -1414,7 +1413,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn suggest_remove_reference(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) -> bool {
|
||||
let mut span = obligation.cause.span;
|
||||
|
@ -1533,11 +1532,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
false
|
||||
}
|
||||
|
||||
fn suggest_remove_await(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
) {
|
||||
fn suggest_remove_await(&self, obligation: &PredicateObligation<'tcx>, err: &mut Diag<'_>) {
|
||||
let hir = self.tcx.hir();
|
||||
if let ObligationCauseCode::AwaitableExpr(hir_id) = obligation.cause.code().peel_derives()
|
||||
&& let hir::Node::Expr(expr) = self.tcx.hir_node(*hir_id)
|
||||
|
@ -1607,7 +1602,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn suggest_change_mut(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) {
|
||||
let points_at_arg = matches!(
|
||||
|
@ -1685,7 +1680,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn suggest_semicolon_removal(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
span: Span,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) -> bool {
|
||||
|
@ -1739,7 +1734,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
/// emitted.
|
||||
fn suggest_impl_trait(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) -> bool {
|
||||
|
@ -1809,7 +1804,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
fn point_at_returns_when_relevant(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
err: &mut Diag<'tcx>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) {
|
||||
match obligation.cause.code().peel_derives() {
|
||||
|
@ -1850,7 +1845,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
cause: &ObligationCauseCode<'tcx>,
|
||||
found_node: Option<Node<'_>>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
) -> Diag<'tcx> {
|
||||
pub(crate) fn build_fn_sig_ty<'tcx>(
|
||||
infcx: &InferCtxt<'tcx>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
|
@ -1921,7 +1916,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
fn note_conflicting_fn_args(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
cause: &ObligationCauseCode<'tcx>,
|
||||
expected: Ty<'tcx>,
|
||||
found: Ty<'tcx>,
|
||||
|
@ -2076,7 +2071,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn note_conflicting_closure_bounds(
|
||||
&self,
|
||||
cause: &ObligationCauseCode<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
err: &mut Diag<'tcx>,
|
||||
) {
|
||||
// First, look for an `ExprBindingObligation`, which means we can get
|
||||
// the uninstantiated predicate list of the called function. And check
|
||||
|
@ -2128,7 +2123,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
fn suggest_fully_qualified_path(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
item_def_id: DefId,
|
||||
span: Span,
|
||||
trait_ref: DefId,
|
||||
|
@ -2195,7 +2190,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
#[instrument(level = "debug", skip_all, fields(?obligation.predicate, ?obligation.cause.span))]
|
||||
fn maybe_note_obligation_cause_for_async_await<G: EmissionGuarantee>(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_, G>,
|
||||
err: &mut Diag<'_, G>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) -> bool {
|
||||
let hir = self.tcx.hir();
|
||||
|
@ -2431,7 +2426,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
#[instrument(level = "debug", skip_all)]
|
||||
fn note_obligation_cause_for_async_await<G: EmissionGuarantee>(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_, G>,
|
||||
err: &mut Diag<'_, G>,
|
||||
interior_or_upvar_span: CoroutineInteriorOrUpvar,
|
||||
is_async: bool,
|
||||
outer_coroutine: Option<DefId>,
|
||||
|
@ -2667,7 +2662,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn note_obligation_cause_code<G: EmissionGuarantee, T>(
|
||||
&self,
|
||||
body_id: LocalDefId,
|
||||
err: &mut DiagnosticBuilder<'_, G>,
|
||||
err: &mut Diag<'_, G>,
|
||||
predicate: T,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
cause_code: &ObligationCauseCode<'tcx>,
|
||||
|
@ -3524,7 +3519,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
)]
|
||||
fn suggest_await_before_try(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
span: Span,
|
||||
|
@ -3582,7 +3577,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn suggest_floating_point_literal(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_ref: &ty::PolyTraitRef<'tcx>,
|
||||
) {
|
||||
let rhs_span = match obligation.cause.code() {
|
||||
|
@ -3606,7 +3601,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn suggest_derive(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) {
|
||||
let Some(diagnostic_name) = self.tcx.get_diagnostic_name(trait_pred.def_id()) else {
|
||||
|
@ -3672,7 +3667,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn suggest_dereferencing_index(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) {
|
||||
if let ObligationCauseCode::ImplDerivedObligation(_) = obligation.cause.code()
|
||||
|
@ -3695,7 +3690,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn note_function_argument_obligation<G: EmissionGuarantee>(
|
||||
&self,
|
||||
body_id: LocalDefId,
|
||||
err: &mut DiagnosticBuilder<'_, G>,
|
||||
err: &mut Diag<'_, G>,
|
||||
arg_hir_id: HirId,
|
||||
parent_code: &ObligationCauseCode<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -3881,7 +3876,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
&self,
|
||||
failed_pred: ty::Predicate<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_, G>,
|
||||
err: &mut Diag<'_, G>,
|
||||
expr: &hir::Expr<'_>,
|
||||
) {
|
||||
let tcx = self.tcx;
|
||||
|
@ -3959,7 +3954,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
param_env: ty::ParamEnv<'tcx>,
|
||||
path_segment: &hir::PathSegment<'_>,
|
||||
args: &[hir::Expr<'_>],
|
||||
err: &mut DiagnosticBuilder<'_, G>,
|
||||
err: &mut Diag<'_, G>,
|
||||
) {
|
||||
let tcx = self.tcx;
|
||||
// Special case for iterator chains, we look at potential failures of `Iterator::Item`
|
||||
|
@ -4060,7 +4055,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
typeck_results: &TypeckResults<'tcx>,
|
||||
type_diffs: Vec<TypeError<'tcx>>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_, G>,
|
||||
err: &mut Diag<'_, G>,
|
||||
) {
|
||||
let mut primary_spans = vec![];
|
||||
let mut span_labels = vec![];
|
||||
|
@ -4296,7 +4291,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
/// the array into a slice.
|
||||
fn suggest_convert_to_slice(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
candidate_impls: &[ImplCandidate<'tcx>],
|
||||
|
@ -4368,7 +4363,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
fn explain_hrtb_projection(
|
||||
&self,
|
||||
diag: &mut DiagnosticBuilder<'_>,
|
||||
diag: &mut Diag<'_>,
|
||||
pred: ty::PolyTraitPredicate<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
cause: &ObligationCause<'tcx>,
|
||||
|
@ -4434,7 +4429,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
fn suggest_desugaring_async_fn_in_trait(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
) {
|
||||
// Don't suggest if RTN is active -- we should prefer a where-clause bound instead.
|
||||
|
@ -4525,7 +4520,7 @@ fn hint_missing_borrow<'tcx>(
|
|||
found: Ty<'tcx>,
|
||||
expected: Ty<'tcx>,
|
||||
found_node: Node<'_>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
) {
|
||||
if matches!(found_node, Node::TraitItem(..)) {
|
||||
return;
|
||||
|
@ -4886,7 +4881,7 @@ pub fn suggest_desugaring_async_fn_to_impl_future_in_trait<'tcx>(
|
|||
/// they are not allowed and if possible suggest alternatives.
|
||||
fn point_at_assoc_type_restriction<G: EmissionGuarantee>(
|
||||
tcx: TyCtxt<'_>,
|
||||
err: &mut DiagnosticBuilder<'_, G>,
|
||||
err: &mut Diag<'_, G>,
|
||||
self_ty_str: &str,
|
||||
trait_name: &str,
|
||||
predicate: ty::Predicate<'_>,
|
||||
|
|
|
@ -21,8 +21,8 @@ use crate::traits::{
|
|||
};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||
use rustc_errors::{
|
||||
codes::*, pluralize, struct_span_code_err, Applicability, DiagnosticBuilder, ErrorGuaranteed,
|
||||
FatalError, MultiSpan, StashKey, StringPart,
|
||||
codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, FatalError,
|
||||
MultiSpan, StashKey, StringPart,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Namespace, Res};
|
||||
|
@ -194,7 +194,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
cause: OverflowCause<'tcx>,
|
||||
span: Span,
|
||||
suggest_increasing_limit: bool,
|
||||
mutate: impl FnOnce(&mut DiagnosticBuilder<'_>),
|
||||
mutate: impl FnOnce(&mut Diag<'_>),
|
||||
) -> ! {
|
||||
let mut err = self.build_overflow_error(cause, span, suggest_increasing_limit);
|
||||
mutate(&mut err);
|
||||
|
@ -207,7 +207,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
cause: OverflowCause<'tcx>,
|
||||
span: Span,
|
||||
suggest_increasing_limit: bool,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
) -> Diag<'tcx> {
|
||||
fn with_short_path<'tcx, T>(tcx: TyCtxt<'tcx>, value: T) -> String
|
||||
where
|
||||
T: fmt::Display + Print<'tcx, FmtPrinter<'tcx, 'tcx>>,
|
||||
|
@ -303,7 +303,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
);
|
||||
}
|
||||
|
||||
fn suggest_new_overflow_limit(&self, err: &mut DiagnosticBuilder<'_>) {
|
||||
fn suggest_new_overflow_limit(&self, err: &mut Diag<'_>) {
|
||||
let suggested_limit = match self.tcx.recursion_limit() {
|
||||
Limit(0) => Limit(2),
|
||||
limit => limit * 2,
|
||||
|
@ -1055,7 +1055,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
trait_ref: ty::TraitRef<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
) -> bool {
|
||||
let span = obligation.cause.span;
|
||||
struct V<'v> {
|
||||
|
@ -1267,7 +1267,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
&self,
|
||||
ty: Ty<'tcx>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
) -> Diag<'tcx> {
|
||||
let span = obligation.cause.span;
|
||||
|
||||
let mut diag = match ty.kind() {
|
||||
|
@ -1845,7 +1845,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
impl_candidates: &[ImplCandidate<'tcx>],
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
body_def_id: LocalDefId,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
other: bool,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> bool {
|
||||
|
@ -1932,7 +1932,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
|
||||
let other = if other { "other " } else { "" };
|
||||
let report = |candidates: Vec<TraitRef<'tcx>>, err: &mut DiagnosticBuilder<'_>| {
|
||||
let report = |candidates: Vec<TraitRef<'tcx>>, err: &mut Diag<'_>| {
|
||||
if candidates.is_empty() {
|
||||
return false;
|
||||
}
|
||||
|
@ -2067,7 +2067,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
obligation: &PredicateObligation<'tcx>,
|
||||
trait_predicate: ty::Binder<'tcx, ty::TraitPredicate<'tcx>>,
|
||||
body_def_id: LocalDefId,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
) {
|
||||
// This is *almost* equivalent to
|
||||
// `obligation.cause.code().peel_derives()`, but it gives us the
|
||||
|
@ -2138,7 +2138,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
/// a probable version mismatch is added to `err`
|
||||
fn note_version_mismatch(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
trait_ref: &ty::PolyTraitRef<'tcx>,
|
||||
) -> bool {
|
||||
let get_trait_impls = |trait_def_id| {
|
||||
|
@ -2607,7 +2607,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
fn annotate_source_of_ambiguity(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
ambiguities: &[ambiguity::Ambiguity],
|
||||
predicate: ty::Predicate<'tcx>,
|
||||
) {
|
||||
|
@ -2750,11 +2750,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
})
|
||||
}
|
||||
|
||||
fn note_obligation_cause(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) {
|
||||
fn note_obligation_cause(&self, err: &mut Diag<'_>, obligation: &PredicateObligation<'tcx>) {
|
||||
// First, attempt to add note to this error with an async-await-specific
|
||||
// message, and fall back to regular note otherwise.
|
||||
if !self.maybe_note_obligation_cause_for_async_await(err, obligation) {
|
||||
|
@ -2783,7 +2779,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
#[instrument(level = "debug", skip_all)]
|
||||
fn suggest_unsized_bound_if_applicable(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) {
|
||||
let ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) =
|
||||
|
@ -2809,12 +2805,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
|
||||
#[instrument(level = "debug", skip_all)]
|
||||
fn maybe_suggest_unsized_generics(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
span: Span,
|
||||
node: Node<'tcx>,
|
||||
) {
|
||||
fn maybe_suggest_unsized_generics(&self, err: &mut Diag<'_>, span: Span, node: Node<'tcx>) {
|
||||
let Some(generics) = node.generics() else {
|
||||
return;
|
||||
};
|
||||
|
@ -2866,7 +2857,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
fn maybe_indirection_for_unsized(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
item: &Item<'tcx>,
|
||||
param: &GenericParam<'tcx>,
|
||||
) -> bool {
|
||||
|
@ -3060,7 +3051,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn add_tuple_trait_message(
|
||||
&self,
|
||||
obligation_cause_code: &ObligationCauseCode<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
) {
|
||||
match obligation_cause_code {
|
||||
ObligationCauseCode::RustCall => {
|
||||
|
@ -3085,7 +3076,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
obligation: &PredicateObligation<'tcx>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
trait_predicate: &ty::PolyTraitPredicate<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
span: Span,
|
||||
is_fn_trait: bool,
|
||||
suggested: bool,
|
||||
|
@ -3166,7 +3157,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn add_help_message_for_fn_trait(
|
||||
&self,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diag<'_>,
|
||||
implemented_kind: ty::ClosureKind,
|
||||
params: ty::Binder<'tcx, Ty<'tcx>>,
|
||||
) {
|
||||
|
@ -3222,7 +3213,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
fn maybe_add_note_for_unsatisfied_const(
|
||||
&self,
|
||||
_trait_predicate: &ty::PolyTraitPredicate<'tcx>,
|
||||
_err: &mut DiagnosticBuilder<'_>,
|
||||
_err: &mut Diag<'_>,
|
||||
_span: Span,
|
||||
) -> UnsatisfiedConst {
|
||||
let unsatisfied_const = UnsatisfiedConst(false);
|
||||
|
@ -3237,7 +3228,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
found_kind: ty::ClosureKind,
|
||||
kind: ty::ClosureKind,
|
||||
trait_prefix: &'static str,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
) -> Diag<'tcx> {
|
||||
let closure_span = self.tcx.def_span(closure_def_id);
|
||||
|
||||
let mut err = ClosureKindMismatch {
|
||||
|
@ -3280,7 +3271,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||
expected_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||
terr: TypeError<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
) -> Diag<'tcx> {
|
||||
let self_ty = found_trait_ref.self_ty().skip_binder();
|
||||
let (cause, terr) = if let ty::Closure(def_id, _) = self_ty.kind() {
|
||||
(
|
||||
|
@ -3300,7 +3291,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
def_id: DefId,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
) -> Diag<'tcx> {
|
||||
let name = match self.tcx.opaque_type_origin(def_id.expect_local()) {
|
||||
hir::OpaqueTyOrigin::FnReturn(_) | hir::OpaqueTyOrigin::AsyncFn(_) => {
|
||||
"opaque type".to_string()
|
||||
|
@ -3341,7 +3332,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
span: Span,
|
||||
found_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||
expected_trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||
) -> Result<DiagnosticBuilder<'tcx>, ErrorGuaranteed> {
|
||||
) -> Result<Diag<'tcx>, ErrorGuaranteed> {
|
||||
let found_trait_ref = self.resolve_vars_if_possible(found_trait_ref);
|
||||
let expected_trait_ref = self.resolve_vars_if_possible(expected_trait_ref);
|
||||
|
||||
|
@ -3440,7 +3431,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
span: Span,
|
||||
) -> Result<DiagnosticBuilder<'tcx>, ErrorGuaranteed> {
|
||||
) -> Result<Diag<'tcx>, ErrorGuaranteed> {
|
||||
if !self.tcx.features().generic_const_exprs {
|
||||
let guar = self
|
||||
.dcx()
|
||||
|
|
|
@ -29,7 +29,7 @@ use crate::traits::ProjectionCacheKey;
|
|||
use crate::traits::Unimplemented;
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::{DiagnosticBuilder, EmissionGuarantee};
|
||||
use rustc_errors::{Diag, EmissionGuarantee};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::BoundRegionConversionTime;
|
||||
|
@ -69,10 +69,7 @@ pub enum IntercrateAmbiguityCause<'tcx> {
|
|||
impl<'tcx> IntercrateAmbiguityCause<'tcx> {
|
||||
/// Emits notes when the overlap is caused by complex intercrate ambiguities.
|
||||
/// See #23980 for details.
|
||||
pub fn add_intercrate_ambiguity_hint<G: EmissionGuarantee>(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_, G>,
|
||||
) {
|
||||
pub fn add_intercrate_ambiguity_hint<G: EmissionGuarantee>(&self, err: &mut Diag<'_, G>) {
|
||||
err.note(self.intercrate_ambiguity_hint());
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use crate::traits::{
|
|||
self, coherence, FutureCompatOverlapErrorKind, ObligationCause, ObligationCtxt,
|
||||
};
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_errors::{codes::*, DelayDm, DiagnosticBuilder, EmissionGuarantee};
|
||||
use rustc_errors::{codes::*, DelayDm, Diag, EmissionGuarantee};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_middle::ty::{GenericArgs, GenericArgsRef};
|
||||
|
@ -392,14 +392,14 @@ fn report_conflicting_impls<'tcx>(
|
|||
) -> Result<(), ErrorGuaranteed> {
|
||||
let impl_span = tcx.def_span(impl_def_id);
|
||||
|
||||
// Work to be done after we've built the DiagnosticBuilder. We have to define it
|
||||
// now because the lint emit methods don't return back the DiagnosticBuilder
|
||||
// that's passed in.
|
||||
// Work to be done after we've built the Diag. We have to define it now
|
||||
// because the lint emit methods don't return back the Diag that's passed
|
||||
// in.
|
||||
fn decorate<'tcx, G: EmissionGuarantee>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
overlap: &OverlapError<'tcx>,
|
||||
impl_span: Span,
|
||||
err: &mut DiagnosticBuilder<'_, G>,
|
||||
err: &mut Diag<'_, G>,
|
||||
) {
|
||||
if (overlap.trait_ref, overlap.self_ty).references_error() {
|
||||
err.downgrade_to_delayed_bug();
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::collections::BTreeMap;
|
|||
use super::NormalizeExt;
|
||||
use super::{ObligationCause, PredicateObligation, SelectionContext};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_errors::Diag;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::{InferCtxt, InferOk};
|
||||
use rustc_middle::ty::GenericArgsRef;
|
||||
|
@ -46,7 +46,7 @@ impl<'tcx> TraitAliasExpansionInfo<'tcx> {
|
|||
/// trait aliases.
|
||||
pub fn label_with_exp_info(
|
||||
&self,
|
||||
diag: &mut DiagnosticBuilder<'_>,
|
||||
diag: &mut Diag<'_>,
|
||||
top_label: &'static str,
|
||||
use_desc: &str,
|
||||
) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue