Remove body_def_id from Inherited
This commit is contained in:
parent
5b99723439
commit
fd34549686
14 changed files with 55 additions and 84 deletions
|
@ -124,11 +124,7 @@ pub trait TypeErrCtxtExt<'tcx> {
|
|||
+ Print<'tcx, FmtPrinter<'tcx, 'tcx>, Output = FmtPrinter<'tcx, 'tcx>>,
|
||||
<T as Print<'tcx, FmtPrinter<'tcx, 'tcx>>>::Error: std::fmt::Debug;
|
||||
|
||||
fn report_fulfillment_errors(
|
||||
&self,
|
||||
errors: &[FulfillmentError<'tcx>],
|
||||
body_def_id: Option<LocalDefId>,
|
||||
) -> ErrorGuaranteed;
|
||||
fn report_fulfillment_errors(&self, errors: &[FulfillmentError<'tcx>]) -> ErrorGuaranteed;
|
||||
|
||||
fn report_overflow_obligation<T>(
|
||||
&self,
|
||||
|
@ -386,11 +382,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
fn report_fulfillment_errors(
|
||||
&self,
|
||||
errors: &[FulfillmentError<'tcx>],
|
||||
body_def_id: Option<LocalDefId>,
|
||||
) -> ErrorGuaranteed {
|
||||
fn report_fulfillment_errors(&self, errors: &[FulfillmentError<'tcx>]) -> ErrorGuaranteed {
|
||||
#[derive(Debug)]
|
||||
struct ErrorDescriptor<'tcx> {
|
||||
predicate: ty::Predicate<'tcx>,
|
||||
|
@ -467,7 +459,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
for from_expansion in [false, true] {
|
||||
for (error, suppressed) in iter::zip(errors, &is_suppressed) {
|
||||
if !suppressed && error.obligation.cause.span.from_expansion() == from_expansion {
|
||||
self.report_fulfillment_error(error, body_def_id);
|
||||
self.report_fulfillment_error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1491,11 +1483,7 @@ trait InferCtxtPrivExt<'tcx> {
|
|||
// `error` occurring implies that `cond` occurs.
|
||||
fn error_implies(&self, cond: ty::Predicate<'tcx>, error: ty::Predicate<'tcx>) -> bool;
|
||||
|
||||
fn report_fulfillment_error(
|
||||
&self,
|
||||
error: &FulfillmentError<'tcx>,
|
||||
body_def_id: Option<LocalDefId>,
|
||||
);
|
||||
fn report_fulfillment_error(&self, error: &FulfillmentError<'tcx>);
|
||||
|
||||
fn report_projection_error(
|
||||
&self,
|
||||
|
@ -1558,11 +1546,7 @@ trait InferCtxtPrivExt<'tcx> {
|
|||
trait_ref_and_ty: ty::Binder<'tcx, (ty::TraitPredicate<'tcx>, Ty<'tcx>)>,
|
||||
) -> PredicateObligation<'tcx>;
|
||||
|
||||
fn maybe_report_ambiguity(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
body_def_id: Option<LocalDefId>,
|
||||
);
|
||||
fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>);
|
||||
|
||||
fn predicate_can_apply(
|
||||
&self,
|
||||
|
@ -1644,11 +1628,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn report_fulfillment_error(
|
||||
&self,
|
||||
error: &FulfillmentError<'tcx>,
|
||||
body_def_id: Option<LocalDefId>,
|
||||
) {
|
||||
fn report_fulfillment_error(&self, error: &FulfillmentError<'tcx>) {
|
||||
match error.code {
|
||||
FulfillmentErrorCode::CodeSelectionError(ref selection_error) => {
|
||||
self.report_selection_error(
|
||||
|
@ -1661,7 +1641,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
self.report_projection_error(&error.obligation, e);
|
||||
}
|
||||
FulfillmentErrorCode::CodeAmbiguity => {
|
||||
self.maybe_report_ambiguity(&error.obligation, body_def_id);
|
||||
self.maybe_report_ambiguity(&error.obligation);
|
||||
}
|
||||
FulfillmentErrorCode::CodeSubtypeError(ref expected_found, ref err) => {
|
||||
self.report_mismatched_types(
|
||||
|
@ -2226,11 +2206,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn maybe_report_ambiguity(
|
||||
&self,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
body_def_id: Option<LocalDefId>,
|
||||
) {
|
||||
fn maybe_report_ambiguity(&self, obligation: &PredicateObligation<'tcx>) {
|
||||
// Unable to successfully determine, probably means
|
||||
// insufficient type information, but could mean
|
||||
// ambiguous impls. The latter *ought* to be a
|
||||
|
@ -2272,7 +2248,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
|
||||
if let None = self.tainted_by_errors() {
|
||||
self.emit_inference_failure_err(
|
||||
body_def_id,
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
trait_ref.self_ty().skip_binder().into(),
|
||||
ErrorCode::E0282,
|
||||
|
@ -2300,7 +2276,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
let mut err = if let Some(subst) = subst {
|
||||
self.emit_inference_failure_err(
|
||||
body_def_id,
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
subst,
|
||||
ErrorCode::E0283,
|
||||
|
@ -2352,7 +2328,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
self.report_similar_impl_candidates(
|
||||
impl_candidates,
|
||||
trait_ref,
|
||||
body_def_id.unwrap_or(obligation.cause.body_id),
|
||||
obligation.cause.body_id,
|
||||
&mut err,
|
||||
false,
|
||||
);
|
||||
|
@ -2374,10 +2350,9 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id());
|
||||
}
|
||||
|
||||
if let (Some(body_def_id), Some(ty::subst::GenericArgKind::Type(_))) =
|
||||
(body_def_id, subst.map(|subst| subst.unpack()))
|
||||
if let Some(ty::subst::GenericArgKind::Type(_)) = subst.map(|subst| subst.unpack())
|
||||
{
|
||||
let body_id = self.tcx.hir().body_owned_by(body_def_id);
|
||||
let body_id = self.tcx.hir().body_owned_by(obligation.cause.body_id);
|
||||
let mut expr_finder = FindExprBySpan::new(span);
|
||||
expr_finder.visit_expr(&self.tcx.hir().body(body_id).value);
|
||||
|
||||
|
@ -2473,7 +2448,13 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
self.emit_inference_failure_err(body_def_id, span, arg, ErrorCode::E0282, false)
|
||||
self.emit_inference_failure_err(
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
arg,
|
||||
ErrorCode::E0282,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
ty::PredicateKind::Subtype(data) => {
|
||||
|
@ -2487,7 +2468,13 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let SubtypePredicate { a_is_expected: _, a, b } = data;
|
||||
// both must be type variables, or the other would've been instantiated
|
||||
assert!(a.is_ty_var() && b.is_ty_var());
|
||||
self.emit_inference_failure_err(body_def_id, span, a.into(), ErrorCode::E0282, true)
|
||||
self.emit_inference_failure_err(
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
a.into(),
|
||||
ErrorCode::E0282,
|
||||
true,
|
||||
)
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(data)) => {
|
||||
if predicate.references_error() || self.tainted_by_errors().is_some() {
|
||||
|
@ -2501,7 +2488,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
.find(|g| g.has_non_region_infer());
|
||||
if let Some(subst) = subst {
|
||||
let mut err = self.emit_inference_failure_err(
|
||||
body_def_id,
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
subst,
|
||||
ErrorCode::E0284,
|
||||
|
@ -2530,7 +2517,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let subst = data.walk().find(|g| g.is_non_region_infer());
|
||||
if let Some(subst) = subst {
|
||||
let err = self.emit_inference_failure_err(
|
||||
body_def_id,
|
||||
obligation.cause.body_id,
|
||||
span,
|
||||
subst,
|
||||
ErrorCode::E0284,
|
||||
|
|
|
@ -210,7 +210,7 @@ fn do_normalize_predicates<'tcx>(
|
|||
let predicates = match fully_normalize(&infcx, cause, elaborated_env, predicates) {
|
||||
Ok(predicates) => predicates,
|
||||
Err(errors) => {
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
|
||||
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
|
||||
return Err(reported);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue