1
Fork 0

Rename things to be a bit clearer

This commit is contained in:
Michael Goulet 2022-12-21 05:53:55 +00:00
parent 0c09e2bf5a
commit 978dd2e3b8

View file

@ -3147,7 +3147,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
err: &mut Diagnostic, err: &mut Diagnostic,
parent_code: &ObligationCauseCode<'tcx>, parent_code: &ObligationCauseCode<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
predicate: ty::Predicate<'tcx>, failed_pred: ty::Predicate<'tcx>,
call_hir_id: HirId, call_hir_id: HirId,
) { ) {
let tcx = self.tcx; let tcx = self.tcx;
@ -3183,31 +3183,28 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = parent_code.deref() if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = parent_code.deref()
&& let Some(node_substs) = typeck_results.node_substs_opt(call_hir_id) && let Some(node_substs) = typeck_results.node_substs_opt(call_hir_id)
&& let predicates = self.tcx.predicates_of(def_id).instantiate(self.tcx, node_substs) && let where_clauses = self.tcx.predicates_of(def_id).instantiate(self.tcx, node_substs)
&& let Some(pred) = predicates.predicates.get(*idx) && let Some(where_pred) = where_clauses.predicates.get(*idx)
{ {
if let Some(trait_pred) = pred.to_opt_poly_trait_pred() if let Some(where_pred) = where_pred.to_opt_poly_trait_pred()
&& let Some(trait_predicate) = predicate.to_opt_poly_trait_pred() && let Some(failed_pred) = failed_pred.to_opt_poly_trait_pred()
{ {
let mut c = CollectAllMismatches { let mut c = CollectAllMismatches {
infcx: self.infcx, infcx: self.infcx,
param_env, param_env,
errors: vec![], errors: vec![],
}; };
if let Ok(_) = c.relate(trait_pred, trait_predicate) { if let Ok(_) = c.relate(where_pred, failed_pred) {
type_diffs = c.errors; type_diffs = c.errors;
} }
} else if let ty::PredicateKind::Clause( } else if let Some(where_pred) = where_pred.to_opt_poly_projection_pred()
ty::Clause::Projection(proj) && let Some(failed_pred) = failed_pred.to_opt_poly_projection_pred()
) = pred.kind().skip_binder() && let Some(found) = failed_pred.skip_binder().term.ty()
&& let ty::PredicateKind::Clause(
ty::Clause::Projection(projection)
) = predicate.kind().skip_binder()
{ {
type_diffs = vec![ type_diffs = vec![
Sorts(ty::error::ExpectedFound { Sorts(ty::error::ExpectedFound {
expected: self.tcx.mk_ty(ty::Alias(ty::Projection, proj.projection_ty)), expected: self.tcx.mk_ty(ty::Alias(ty::Projection, where_pred.skip_binder().projection_ty)),
found: projection.term.ty().unwrap(), found,
}), }),
]; ];
} }