@@ -78,15 +78,16 @@ fn compare_predicate_entailment<'tcx>(
7878 // `regionck_item` expects.
7979 let impl_m_hir_id = tcx. hir ( ) . as_local_hir_id ( impl_m. def_id . expect_local ( ) ) ;
8080
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 {
8586 item_name : impl_m. ident . name ,
8687 impl_item_def_id : impl_m. def_id ,
8788 trait_item_def_id : trait_m. def_id ,
8889 } ,
89- } ;
90+ ) ;
9091
9192 // This code is best explained by example. Consider a trait:
9293 //
@@ -280,7 +281,7 @@ fn compare_predicate_entailment<'tcx>(
280281 & infcx, param_env, & terr, & cause, impl_m, impl_sig, trait_m, trait_sig,
281282 ) ;
282283
283- let cause = ObligationCause { span : impl_err_span, ..cause } ;
284+ cause. make_mut ( ) . span = impl_err_span;
284285
285286 let mut diag = struct_span_err ! (
286287 tcx. sess,
@@ -965,8 +966,11 @@ crate fn compare_const_impl<'tcx>(
965966 // Compute placeholder form of impl and trait const tys.
966967 let impl_ty = tcx. type_of ( impl_c. def_id ) ;
967968 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+ ) ;
970974
971975 // There is no "body" here, so just pass dummy id.
972976 let impl_ty =
@@ -992,7 +996,7 @@ crate fn compare_const_impl<'tcx>(
992996
993997 // Locate the Span containing just the type of the offending impl
994998 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 ,
9961000 _ => bug ! ( "{:?} is not a impl const" , impl_c) ,
9971001 }
9981002
@@ -1095,15 +1099,15 @@ fn compare_type_predicate_entailment(
10951099 // `ObligationCause` (and the `FnCtxt`). This is what
10961100 // `regionck_item` expects.
10971101 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 {
11021106 item_name : impl_ty. ident . name ,
11031107 impl_item_def_id : impl_ty. def_id ,
11041108 trait_item_def_id : trait_ty. def_id ,
11051109 } ,
1106- } ;
1110+ ) ;
11071111
11081112 debug ! ( "compare_type_predicate_entailment: trait_to_impl_substs={:?}" , trait_to_impl_substs) ;
11091113
0 commit comments