Consolidate obligation cause codes for where clauses

This commit is contained in:
Michael Goulet 2024-05-10 11:04:53 -04:00
parent ef15976387
commit e444017b49
25 changed files with 137 additions and 139 deletions

View file

@ -819,7 +819,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx> {
ObligationCause::new(
self.span,
self.body_id,
ObligationCauseCode::SpannedWhereClause(proj.def_id, pred_span),
ObligationCauseCode::WhereClause(proj.def_id, pred_span),
),
self.param_env,
pred,
@ -2011,11 +2011,7 @@ pub(super) fn check_type_bounds<'tcx>(
},
);
let mk_cause = |span: Span| {
let code = if span.is_dummy() {
ObligationCauseCode::WhereClause(trait_ty.def_id)
} else {
ObligationCauseCode::SpannedWhereClause(trait_ty.def_id, span)
};
let code = ObligationCauseCode::WhereClause(trait_ty.def_id, span);
ObligationCause::new(impl_ty_span, impl_ty_def_id, code)
};
@ -2251,8 +2247,7 @@ fn try_report_async_mismatch<'tcx>(
};
for error in errors {
if let ObligationCauseCode::SpannedWhereClause(def_id, _) =
*error.root_obligation.cause.code()
if let ObligationCauseCode::WhereClause(def_id, _) = *error.root_obligation.cause.code()
&& def_id == async_future_def_id
&& let Some(proj) = error.root_obligation.predicate.to_opt_poly_projection_pred()
&& let Some(proj) = proj.no_bound_vars()

View file

@ -1550,7 +1550,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
let cause = traits::ObligationCause::new(
sp,
wfcx.body_def_id,
ObligationCauseCode::WhereClause(def_id.to_def_id()),
ObligationCauseCode::WhereClause(def_id.to_def_id(), DUMMY_SP),
);
traits::Obligation::new(tcx, cause, wfcx.param_env, pred)
});

View file

@ -212,7 +212,7 @@ fn get_impl_args(
traits::ObligationCause::new(
impl1_span,
impl1_def_id,
traits::ObligationCauseCode::SpannedWhereClause(impl2_node.def_id(), span),
traits::ObligationCauseCode::WhereClause(impl2_node.def_id(), span),
)
},
);