Skip to content

Commit 3c9b30e

Browse files
committed
Define all clauses as dummy_with_span as the usages are all equivalent
1 parent aaa1db6 commit 3c9b30e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

compiler/rustc_traits/src/type_op.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>(
5959

6060
let UserSubsts { user_self_ty, substs } = user_substs;
6161
let tcx = ocx.infcx.tcx;
62+
let cause = ObligationCause::dummy_with_span(span);
6263

6364
let ty = tcx.bound_type_of(def_id).subst(tcx, substs);
64-
let ty = ocx.normalize(ObligationCause::misc(span, hir::CRATE_HIR_ID), param_env, ty);
65+
let ty = ocx.normalize(cause.clone(), param_env, ty);
6566
debug!("relate_type_and_user_type: ty of def-id is {:?}", ty);
6667

67-
ocx.eq(&ObligationCause::dummy_with_span(span), param_env, mir_ty, ty)?;
68+
ocx.eq(&cause, param_env, mir_ty, ty)?;
6869

6970
// Prove the predicates coming along with `def_id`.
7071
//
@@ -73,8 +74,6 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>(
7374
// outlives" error messages.
7475
let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, substs);
7576

76-
let cause = ObligationCause::dummy_with_span(span);
77-
7877
debug!(?instantiated_predicates);
7978
for (instantiated_predicate, predicate_span) in
8079
zip(instantiated_predicates.predicates, instantiated_predicates.spans)
@@ -93,10 +92,9 @@ pub fn type_op_ascribe_user_type_with_span<'tcx>(
9392

9493
if let Some(UserSelfTy { impl_def_id, self_ty }) = user_self_ty {
9594
let impl_self_ty = tcx.bound_type_of(impl_def_id).subst(tcx, substs);
96-
let impl_self_ty =
97-
ocx.normalize(ObligationCause::misc(span, hir::CRATE_HIR_ID), param_env, impl_self_ty);
95+
let impl_self_ty = ocx.normalize(cause.clone(), param_env, impl_self_ty);
9896

99-
ocx.eq(&ObligationCause::dummy_with_span(span), param_env, self_ty, impl_self_ty)?;
97+
ocx.eq(&cause, param_env, self_ty, impl_self_ty)?;
10098

10199
let predicate: Predicate<'tcx> =
102100
ty::Binder::dummy(ty::PredicateKind::WellFormed(impl_self_ty.into())).to_predicate(tcx);

0 commit comments

Comments
 (0)