@@ -78,15 +78,16 @@ fn compare_predicate_entailment<'tcx>(
78
78
// `regionck_item` expects.
79
79
let impl_m_hir_id = tcx. hir ( ) . as_local_hir_id ( impl_m. def_id . expect_local ( ) ) ;
80
80
81
- let cause = ObligationCause {
82
- span : impl_m_span,
83
- body_id : impl_m_hir_id,
84
- code : ObligationCauseCode :: CompareImplMethodObligation {
81
+ // We sometimes modify the span further down.
82
+ let mut cause = ObligationCause :: new (
83
+ impl_m_span,
84
+ impl_m_hir_id,
85
+ ObligationCauseCode :: CompareImplMethodObligation {
85
86
item_name : impl_m. ident . name ,
86
87
impl_item_def_id : impl_m. def_id ,
87
88
trait_item_def_id : trait_m. def_id ,
88
89
} ,
89
- } ;
90
+ ) ;
90
91
91
92
// This code is best explained by example. Consider a trait:
92
93
//
@@ -280,7 +281,7 @@ fn compare_predicate_entailment<'tcx>(
280
281
& infcx, param_env, & terr, & cause, impl_m, impl_sig, trait_m, trait_sig,
281
282
) ;
282
283
283
- let cause = ObligationCause { span : impl_err_span, ..cause } ;
284
+ cause. make_mut ( ) . span = impl_err_span;
284
285
285
286
let mut diag = struct_span_err ! (
286
287
tcx. sess,
@@ -965,8 +966,11 @@ crate fn compare_const_impl<'tcx>(
965
966
// Compute placeholder form of impl and trait const tys.
966
967
let impl_ty = tcx. type_of ( impl_c. def_id ) ;
967
968
let trait_ty = tcx. type_of ( trait_c. def_id ) . subst ( tcx, trait_to_impl_substs) ;
968
- let mut cause = ObligationCause :: misc ( impl_c_span, impl_c_hir_id) ;
969
- cause. code = ObligationCauseCode :: CompareImplConstObligation ;
969
+ let mut cause = ObligationCause :: new (
970
+ impl_c_span,
971
+ impl_c_hir_id,
972
+ ObligationCauseCode :: CompareImplConstObligation ,
973
+ ) ;
970
974
971
975
// There is no "body" here, so just pass dummy id.
972
976
let impl_ty =
@@ -992,7 +996,7 @@ crate fn compare_const_impl<'tcx>(
992
996
993
997
// Locate the Span containing just the type of the offending impl
994
998
match tcx. hir ( ) . expect_impl_item ( impl_c_hir_id) . kind {
995
- ImplItemKind :: Const ( ref ty, _) => cause. span = ty. span ,
999
+ ImplItemKind :: Const ( ref ty, _) => cause. make_mut ( ) . span = ty. span ,
996
1000
_ => bug ! ( "{:?} is not a impl const" , impl_c) ,
997
1001
}
998
1002
@@ -1095,15 +1099,15 @@ fn compare_type_predicate_entailment(
1095
1099
// `ObligationCause` (and the `FnCtxt`). This is what
1096
1100
// `regionck_item` expects.
1097
1101
let impl_ty_hir_id = tcx. hir ( ) . as_local_hir_id ( impl_ty. def_id . expect_local ( ) ) ;
1098
- let cause = ObligationCause {
1099
- span : impl_ty_span,
1100
- body_id : impl_ty_hir_id,
1101
- code : ObligationCauseCode :: CompareImplTypeObligation {
1102
+ let cause = ObligationCause :: new (
1103
+ impl_ty_span,
1104
+ impl_ty_hir_id,
1105
+ ObligationCauseCode :: CompareImplTypeObligation {
1102
1106
item_name : impl_ty. ident . name ,
1103
1107
impl_item_def_id : impl_ty. def_id ,
1104
1108
trait_item_def_id : trait_ty. def_id ,
1105
1109
} ,
1106
- } ;
1110
+ ) ;
1107
1111
1108
1112
debug ! ( "compare_type_predicate_entailment: trait_to_impl_substs={:?}" , trait_to_impl_substs) ;
1109
1113
0 commit comments