Replace &mut DiagnosticBuilder
, in signatures, with &mut Diagnostic
.
This commit is contained in:
parent
f24ff1815f
commit
02ff9e0aef
65 changed files with 369 additions and 466 deletions
|
@ -14,6 +14,7 @@ use crate::traits::{
|
|||
PredicateObligations, SelectionContext,
|
||||
};
|
||||
//use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_hir::CRATE_HIR_ID;
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
|
@ -50,7 +51,7 @@ pub struct OverlapResult<'tcx> {
|
|||
pub involves_placeholder: bool,
|
||||
}
|
||||
|
||||
pub fn add_placeholder_note(err: &mut rustc_errors::DiagnosticBuilder<'_>) {
|
||||
pub fn add_placeholder_note(err: &mut Diagnostic) {
|
||||
err.note(
|
||||
"this behavior recently changed as a result of a bug fix; \
|
||||
see rust-lang/rust#56105 for details",
|
||||
|
|
|
@ -12,7 +12,9 @@ use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCod
|
|||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use crate::infer::{self, InferCtxt, TyCtxtInferExt};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, ErrorReported};
|
||||
use rustc_errors::{
|
||||
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
|
@ -1174,7 +1176,7 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
|
|||
fn report_similar_impl_candidates(
|
||||
&self,
|
||||
impl_candidates: Vec<ImplCandidate<'tcx>>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
);
|
||||
|
||||
/// Gets the parent trait chain start
|
||||
|
@ -1186,11 +1188,7 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
|
|||
/// If the `Self` type of the unsatisfied trait `trait_ref` implements a trait
|
||||
/// with the same path as `trait_ref`, a help message about
|
||||
/// a probable version mismatch is added to `err`
|
||||
fn note_version_mismatch(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
trait_ref: &ty::PolyTraitRef<'tcx>,
|
||||
);
|
||||
fn note_version_mismatch(&self, err: &mut Diagnostic, trait_ref: &ty::PolyTraitRef<'tcx>);
|
||||
|
||||
/// Creates a `PredicateObligation` with `new_self_ty` replacing the existing type in the
|
||||
/// `trait_ref`.
|
||||
|
@ -1215,35 +1213,26 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
|
|||
pred: ty::PolyTraitRef<'tcx>,
|
||||
) -> bool;
|
||||
|
||||
fn note_obligation_cause(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
);
|
||||
fn note_obligation_cause(&self, err: &mut Diagnostic, obligation: &PredicateObligation<'tcx>);
|
||||
|
||||
fn suggest_unsized_bound_if_applicable(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
err: &mut Diagnostic,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
);
|
||||
|
||||
fn annotate_source_of_ambiguity(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
err: &mut Diagnostic,
|
||||
impls: &[DefId],
|
||||
predicate: ty::Predicate<'tcx>,
|
||||
);
|
||||
|
||||
fn maybe_suggest_unsized_generics(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
span: Span,
|
||||
node: Node<'hir>,
|
||||
);
|
||||
fn maybe_suggest_unsized_generics(&self, err: &mut Diagnostic, span: Span, node: Node<'hir>);
|
||||
|
||||
fn maybe_indirection_for_unsized(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
err: &mut Diagnostic,
|
||||
item: &'hir Item<'hir>,
|
||||
param: &'hir GenericParam<'hir>,
|
||||
) -> bool;
|
||||
|
@ -1572,7 +1561,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
fn report_similar_impl_candidates(
|
||||
&self,
|
||||
impl_candidates: Vec<ImplCandidate<'tcx>>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
) {
|
||||
if impl_candidates.is_empty() {
|
||||
return;
|
||||
|
@ -1649,11 +1638,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
/// If the `Self` type of the unsatisfied trait `trait_ref` implements a trait
|
||||
/// with the same path as `trait_ref`, a help message about
|
||||
/// a probable version mismatch is added to `err`
|
||||
fn note_version_mismatch(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
trait_ref: &ty::PolyTraitRef<'tcx>,
|
||||
) {
|
||||
fn note_version_mismatch(&self, err: &mut Diagnostic, trait_ref: &ty::PolyTraitRef<'tcx>) {
|
||||
let get_trait_impl = |trait_def_id| {
|
||||
self.tcx.find_map_relevant_impl(trait_def_id, trait_ref.skip_binder().self_ty(), Some)
|
||||
};
|
||||
|
@ -1944,7 +1929,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
fn annotate_source_of_ambiguity(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
err: &mut Diagnostic,
|
||||
impls: &[DefId],
|
||||
predicate: ty::Predicate<'tcx>,
|
||||
) {
|
||||
|
@ -2088,11 +2073,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
})
|
||||
}
|
||||
|
||||
fn note_obligation_cause(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) {
|
||||
fn note_obligation_cause(&self, err: &mut Diagnostic, 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) {
|
||||
|
@ -2110,7 +2091,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
fn suggest_unsized_bound_if_applicable(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
err: &mut Diagnostic,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) {
|
||||
let (pred, item_def_id, span) = match (
|
||||
|
@ -2139,7 +2120,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
fn maybe_suggest_unsized_generics<'hir>(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
err: &mut Diagnostic,
|
||||
span: Span,
|
||||
node: Node<'hir>,
|
||||
) {
|
||||
|
@ -2206,7 +2187,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
fn maybe_indirection_for_unsized<'hir>(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
err: &mut Diagnostic,
|
||||
item: &'hir Item<'hir>,
|
||||
param: &'hir GenericParam<'hir>,
|
||||
) -> bool {
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::traits::normalize_projection_type;
|
|||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::{
|
||||
error_code, pluralize, struct_span_err, Applicability, DiagnosticBuilder, Style,
|
||||
error_code, pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, Style,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
|
@ -47,7 +47,7 @@ pub enum GeneratorInteriorOrUpvar {
|
|||
pub trait InferCtxtExt<'tcx> {
|
||||
fn suggest_restricting_param_bound(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
body_id: hir::HirId,
|
||||
);
|
||||
|
@ -55,28 +55,23 @@ pub trait InferCtxtExt<'tcx> {
|
|||
fn suggest_dereferences(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
err: &mut Diagnostic,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
);
|
||||
|
||||
fn get_closure_name(
|
||||
&self,
|
||||
def_id: DefId,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
msg: &str,
|
||||
) -> Option<String>;
|
||||
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<String>;
|
||||
|
||||
fn suggest_fn_call(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
);
|
||||
|
||||
fn suggest_add_reference_to_arg(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
has_custom_message: bool,
|
||||
) -> bool;
|
||||
|
@ -84,27 +79,23 @@ pub trait InferCtxtExt<'tcx> {
|
|||
fn suggest_remove_reference(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
);
|
||||
|
||||
fn suggest_remove_await(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
);
|
||||
fn suggest_remove_await(&self, obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic);
|
||||
|
||||
fn suggest_change_mut(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
);
|
||||
|
||||
fn suggest_semicolon_removal(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
span: Span,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
);
|
||||
|
@ -113,7 +104,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||
|
||||
fn suggest_impl_trait(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
span: Span,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
|
@ -121,7 +112,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||
|
||||
fn point_at_returns_when_relevant(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
);
|
||||
|
||||
|
@ -135,7 +126,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||
|
||||
fn suggest_fully_qualified_path(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
def_id: DefId,
|
||||
span: Span,
|
||||
trait_ref: DefId,
|
||||
|
@ -143,13 +134,13 @@ pub trait InferCtxtExt<'tcx> {
|
|||
|
||||
fn maybe_note_obligation_cause_for_async_await(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) -> bool;
|
||||
|
||||
fn note_obligation_cause_for_async_await(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
interior_or_upvar_span: GeneratorInteriorOrUpvar,
|
||||
interior_extra_info: Option<(Option<Span>, Span, Option<hir::HirId>, Option<Span>)>,
|
||||
inner_generator_body: Option<&hir::Body<'tcx>>,
|
||||
|
@ -163,7 +154,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||
|
||||
fn note_obligation_cause_code<T>(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
predicate: &T,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
cause_code: &ObligationCauseCode<'tcx>,
|
||||
|
@ -172,12 +163,12 @@ pub trait InferCtxtExt<'tcx> {
|
|||
) where
|
||||
T: fmt::Display;
|
||||
|
||||
fn suggest_new_overflow_limit(&self, err: &mut DiagnosticBuilder<'_>);
|
||||
fn suggest_new_overflow_limit(&self, err: &mut Diagnostic);
|
||||
|
||||
/// Suggest to await before try: future? => future.await?
|
||||
fn suggest_await_before_try(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
span: Span,
|
||||
|
@ -202,7 +193,7 @@ fn suggest_restriction<'tcx>(
|
|||
tcx: TyCtxt<'tcx>,
|
||||
generics: &hir::Generics<'tcx>,
|
||||
msg: &str,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
fn_sig: Option<&hir::FnSig<'_>>,
|
||||
projection: Option<&ty::ProjectionTy<'_>>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
|
@ -329,7 +320,7 @@ fn suggest_restriction<'tcx>(
|
|||
impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
fn suggest_restricting_param_bound(
|
||||
&self,
|
||||
mut err: &mut DiagnosticBuilder<'_>,
|
||||
mut err: &mut Diagnostic,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
body_id: hir::HirId,
|
||||
) {
|
||||
|
@ -493,7 +484,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
fn suggest_dereferences(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'tcx>,
|
||||
err: &mut Diagnostic,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) {
|
||||
// It only make sense when suggesting dereferences for arguments
|
||||
|
@ -549,26 +540,20 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
/// Given a closure's `DefId`, return the given name of the closure.
|
||||
///
|
||||
/// This doesn't account for reassignments, but it's only used for suggestions.
|
||||
fn get_closure_name(
|
||||
&self,
|
||||
def_id: DefId,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
msg: &str,
|
||||
) -> Option<String> {
|
||||
let get_name =
|
||||
|err: &mut DiagnosticBuilder<'_>, kind: &hir::PatKind<'_>| -> Option<String> {
|
||||
// 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::Unannotated, _, name, None) => {
|
||||
Some(format!("{}", name))
|
||||
}
|
||||
_ => {
|
||||
err.note(&msg);
|
||||
None
|
||||
}
|
||||
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<String> {
|
||||
let get_name = |err: &mut Diagnostic, kind: &hir::PatKind<'_>| -> Option<String> {
|
||||
// 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::Unannotated, _, name, None) => {
|
||||
Some(format!("{}", name))
|
||||
}
|
||||
};
|
||||
_ => {
|
||||
err.note(&msg);
|
||||
None
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let hir = self.tcx.hir();
|
||||
let hir_id = hir.local_def_id_to_hir_id(def_id.as_local()?);
|
||||
|
@ -590,7 +575,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
fn suggest_fn_call(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) {
|
||||
let self_ty = match trait_pred.self_ty().no_bound_vars() {
|
||||
|
@ -683,7 +668,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
fn suggest_add_reference_to_arg(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
poly_trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
has_custom_message: bool,
|
||||
) -> bool {
|
||||
|
@ -817,7 +802,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
fn suggest_remove_reference(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) {
|
||||
let span = obligation.cause.span;
|
||||
|
@ -874,11 +859,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn suggest_remove_await(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
) {
|
||||
fn suggest_remove_await(&self, obligation: &PredicateObligation<'tcx>, err: &mut Diagnostic) {
|
||||
let span = obligation.cause.span;
|
||||
|
||||
if let ObligationCauseCode::AwaitableExpr(hir_id) = obligation.cause.code().peel_derives() {
|
||||
|
@ -936,7 +917,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
fn suggest_change_mut(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) {
|
||||
let points_at_arg = matches!(
|
||||
|
@ -1012,7 +993,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
fn suggest_semicolon_removal(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
span: Span,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) {
|
||||
|
@ -1063,7 +1044,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
/// emitted.
|
||||
fn suggest_impl_trait(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
span: Span,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
|
@ -1256,7 +1237,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
fn point_at_returns_when_relevant(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) {
|
||||
match obligation.cause.code().peel_derives() {
|
||||
|
@ -1345,7 +1326,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
fn suggest_fully_qualified_path(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
def_id: DefId,
|
||||
span: Span,
|
||||
trait_ref: DefId,
|
||||
|
@ -1411,7 +1392,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
/// Returns `true` if an async-await specific note was added to the diagnostic.
|
||||
fn maybe_note_obligation_cause_for_async_await(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) -> bool {
|
||||
debug!(
|
||||
|
@ -1639,7 +1620,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
/// `maybe_note_obligation_cause_for_async_await`'s documentation comment.
|
||||
fn note_obligation_cause_for_async_await(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
interior_or_upvar_span: GeneratorInteriorOrUpvar,
|
||||
interior_extra_info: Option<(Option<Span>, Span, Option<hir::HirId>, Option<Span>)>,
|
||||
inner_generator_body: Option<&hir::Body<'tcx>>,
|
||||
|
@ -1896,7 +1877,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
fn note_obligation_cause_code<T>(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
predicate: &T,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
cause_code: &ObligationCauseCode<'tcx>,
|
||||
|
@ -2412,7 +2393,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn suggest_new_overflow_limit(&self, err: &mut DiagnosticBuilder<'_>) {
|
||||
fn suggest_new_overflow_limit(&self, err: &mut Diagnostic) {
|
||||
let suggested_limit = match self.tcx.recursion_limit() {
|
||||
Limit(0) => Limit(2),
|
||||
limit => limit * 2,
|
||||
|
@ -2427,7 +2408,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
fn suggest_await_before_try(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
span: Span,
|
||||
|
@ -2615,7 +2596,7 @@ impl NextTypeParamName for &[hir::GenericParam<'_>] {
|
|||
}
|
||||
|
||||
fn suggest_trait_object_return_type_alternatives(
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
ret_ty: Span,
|
||||
trait_obj: &str,
|
||||
is_object_safe: bool,
|
||||
|
|
|
@ -29,7 +29,7 @@ use crate::traits::project::ProjectionCacheKeyExt;
|
|||
use crate::traits::ProjectionCacheKey;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::{Diagnostic, ErrorReported};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::LateBoundRegionConversionTime;
|
||||
|
@ -64,7 +64,7 @@ pub enum IntercrateAmbiguityCause {
|
|||
impl IntercrateAmbiguityCause {
|
||||
/// Emits notes when the overlap is caused by complex intercrate ambiguities.
|
||||
/// See #23980 for details.
|
||||
pub fn add_intercrate_ambiguity_hint(&self, err: &mut rustc_errors::DiagnosticBuilder<'_>) {
|
||||
pub fn add_intercrate_ambiguity_hint(&self, err: &mut Diagnostic) {
|
||||
err.note(&self.intercrate_ambiguity_hint());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_span::Span;
|
||||
use smallvec::smallvec;
|
||||
use smallvec::SmallVec;
|
||||
|
@ -43,12 +43,7 @@ impl<'tcx> TraitAliasExpansionInfo<'tcx> {
|
|||
|
||||
/// Adds diagnostic labels to `diag` for the expansion path of a trait through all intermediate
|
||||
/// trait aliases.
|
||||
pub fn label_with_exp_info(
|
||||
&self,
|
||||
diag: &mut DiagnosticBuilder<'_>,
|
||||
top_label: &str,
|
||||
use_desc: &str,
|
||||
) {
|
||||
pub fn label_with_exp_info(&self, diag: &mut Diagnostic, top_label: &str, use_desc: &str) {
|
||||
diag.span_label(self.top().1, top_label);
|
||||
if self.path.len() > 1 {
|
||||
for (_, sp) in self.path.iter().rev().skip(1).take(self.path.len() - 2) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue