Define all clauses as dummy_with_span as the usages are all equivalent

This commit is contained in:
Santiago Pastorino 2022-11-25 15:36:15 -03:00
parent aaa1db63ce
commit 3c9b30e658
No known key found for this signature in database
GPG Key ID: 8131A24E0C79EFAF

View File

@ -59,12 +59,13 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>(
let UserSubsts { user_self_ty, substs } = user_substs; let UserSubsts { user_self_ty, substs } = user_substs;
let tcx = ocx.infcx.tcx; let tcx = ocx.infcx.tcx;
let cause = ObligationCause::dummy_with_span(span);
let ty = tcx.bound_type_of(def_id).subst(tcx, substs); let ty = tcx.bound_type_of(def_id).subst(tcx, substs);
let ty = ocx.normalize(ObligationCause::misc(span, hir::CRATE_HIR_ID), param_env, ty); let ty = ocx.normalize(cause.clone(), param_env, ty);
debug!("relate_type_and_user_type: ty of def-id is {:?}", ty); debug!("relate_type_and_user_type: ty of def-id is {:?}", ty);
ocx.eq(&ObligationCause::dummy_with_span(span), param_env, mir_ty, ty)?; ocx.eq(&cause, param_env, mir_ty, ty)?;
// Prove the predicates coming along with `def_id`. // Prove the predicates coming along with `def_id`.
// //
@ -73,8 +74,6 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>(
// outlives" error messages. // outlives" error messages.
let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, substs); let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, substs);
let cause = ObligationCause::dummy_with_span(span);
debug!(?instantiated_predicates); debug!(?instantiated_predicates);
for (instantiated_predicate, predicate_span) in for (instantiated_predicate, predicate_span) in
zip(instantiated_predicates.predicates, instantiated_predicates.spans) zip(instantiated_predicates.predicates, instantiated_predicates.spans)
@ -93,10 +92,9 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>(
if let Some(UserSelfTy { impl_def_id, self_ty }) = user_self_ty { if let Some(UserSelfTy { impl_def_id, self_ty }) = user_self_ty {
let impl_self_ty = tcx.bound_type_of(impl_def_id).subst(tcx, substs); let impl_self_ty = tcx.bound_type_of(impl_def_id).subst(tcx, substs);
let impl_self_ty = let impl_self_ty = ocx.normalize(cause.clone(), param_env, impl_self_ty);
ocx.normalize(ObligationCause::misc(span, hir::CRATE_HIR_ID), param_env, impl_self_ty);
ocx.eq(&ObligationCause::dummy_with_span(span), param_env, self_ty, impl_self_ty)?; ocx.eq(&cause, param_env, self_ty, impl_self_ty)?;
let predicate: Predicate<'tcx> = let predicate: Predicate<'tcx> =
ty::Binder::dummy(ty::PredicateKind::WellFormed(impl_self_ty.into())).to_predicate(tcx); ty::Binder::dummy(ty::PredicateKind::WellFormed(impl_self_ty.into())).to_predicate(tcx);