@@ -147,12 +147,12 @@ fn compare_method_predicate_entailment<'tcx>(
147147 //
148148 // FIXME(@lcnr): remove that after removing `cause.body_id` from
149149 // obligations.
150- let impl_m_hir_id = tcx . hir ( ) . local_def_id_to_hir_id ( impl_m. def_id . expect_local ( ) ) ;
150+ let impl_m_def_id = impl_m. def_id . expect_local ( ) ;
151151 let cause = ObligationCause :: new (
152152 impl_m_span,
153- impl_m_hir_id ,
153+ impl_m_def_id ,
154154 ObligationCauseCode :: CompareImplItemObligation {
155- impl_item_def_id : impl_m . def_id . expect_local ( ) ,
155+ impl_item_def_id : impl_m_def_id ,
156156 trait_item_def_id : trait_m. def_id ,
157157 kind : impl_m. kind ,
158158 } ,
@@ -198,7 +198,7 @@ fn compare_method_predicate_entailment<'tcx>(
198198 // Construct trait parameter environment and then shift it into the placeholder viewpoint.
199199 // The key step here is to update the caller_bounds's predicates to be
200200 // the new hybrid bounds we computed.
201- let normalize_cause = traits:: ObligationCause :: misc ( impl_m_span, impl_m_hir_id ) ;
201+ let normalize_cause = traits:: ObligationCause :: misc ( impl_m_span, impl_m_def_id ) ;
202202 let param_env = ty:: ParamEnv :: new (
203203 tcx. intern_predicates ( & hybrid_preds. predicates ) ,
204204 Reveal :: UserFacing ,
@@ -213,14 +213,14 @@ fn compare_method_predicate_entailment<'tcx>(
213213
214214 let impl_m_own_bounds = impl_m_predicates. instantiate_own ( tcx, impl_to_placeholder_substs) ;
215215 for ( predicate, span) in impl_m_own_bounds {
216- let normalize_cause = traits:: ObligationCause :: misc ( span, impl_m_hir_id ) ;
216+ let normalize_cause = traits:: ObligationCause :: misc ( span, impl_m_def_id ) ;
217217 let predicate = ocx. normalize ( & normalize_cause, param_env, predicate) ;
218218
219219 let cause = ObligationCause :: new (
220220 span,
221- impl_m_hir_id ,
221+ impl_m_def_id ,
222222 ObligationCauseCode :: CompareImplItemObligation {
223- impl_item_def_id : impl_m . def_id . expect_local ( ) ,
223+ impl_item_def_id : impl_m_def_id ,
224224 trait_item_def_id : trait_m. def_id ,
225225 kind : impl_m. kind ,
226226 } ,
@@ -253,7 +253,7 @@ fn compare_method_predicate_entailment<'tcx>(
253253 ) ;
254254 let unnormalized_impl_fty = tcx. mk_fn_ptr ( ty:: Binder :: dummy ( unnormalized_impl_sig) ) ;
255255
256- let norm_cause = ObligationCause :: misc ( impl_m_span, impl_m_hir_id ) ;
256+ let norm_cause = ObligationCause :: misc ( impl_m_span, impl_m_def_id ) ;
257257 let impl_sig = ocx. normalize ( & norm_cause, param_env, unnormalized_impl_sig) ;
258258 debug ! ( "compare_impl_method: impl_fty={:?}" , impl_sig) ;
259259
@@ -311,6 +311,7 @@ fn compare_method_predicate_entailment<'tcx>(
311311 if !errors. is_empty ( ) {
312312 match check_implied_wf {
313313 CheckImpliedWfMode :: Check => {
314+ let impl_m_hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( impl_m_def_id) ;
314315 return compare_method_predicate_entailment (
315316 tcx,
316317 impl_m,
@@ -336,7 +337,7 @@ fn compare_method_predicate_entailment<'tcx>(
336337 let outlives_env = OutlivesEnvironment :: with_bounds (
337338 param_env,
338339 Some ( infcx) ,
339- infcx. implied_bounds_tys ( param_env, impl_m_hir_id , wf_tys. clone ( ) ) ,
340+ infcx. implied_bounds_tys ( param_env, impl_m_def_id , wf_tys. clone ( ) ) ,
340341 ) ;
341342 infcx. process_registered_region_obligations (
342343 outlives_env. region_bound_pairs ( ) ,
@@ -346,6 +347,7 @@ fn compare_method_predicate_entailment<'tcx>(
346347 if !errors. is_empty ( ) {
347348 // FIXME(compiler-errors): This can be simplified when IMPLIED_BOUNDS_ENTAILMENT
348349 // becomes a hard error (i.e. ideally we'd just call `resolve_regions_and_report_errors`
350+ let impl_m_hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( impl_m_def_id) ;
349351 match check_implied_wf {
350352 CheckImpliedWfMode :: Check => {
351353 return compare_method_predicate_entailment (
@@ -371,7 +373,7 @@ fn compare_method_predicate_entailment<'tcx>(
371373 }
372374 CheckImpliedWfMode :: Skip => {
373375 if infcx. tainted_by_errors ( ) . is_none ( ) {
374- infcx. err_ctxt ( ) . report_region_errors ( impl_m . def_id . expect_local ( ) , & errors) ;
376+ infcx. err_ctxt ( ) . report_region_errors ( impl_m_def_id , & errors) ;
375377 }
376378 return Err ( tcx
377379 . sess
@@ -610,13 +612,14 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
610612
611613 let trait_to_impl_substs = impl_trait_ref. substs ;
612614
613- let impl_m_hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( impl_m. def_id . expect_local ( ) ) ;
615+ let impl_m_def_id = impl_m. def_id . expect_local ( ) ;
616+ let impl_m_hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( impl_m_def_id) ;
614617 let return_span = tcx. hir ( ) . fn_decl_by_hir_id ( impl_m_hir_id) . unwrap ( ) . output . span ( ) ;
615618 let cause = ObligationCause :: new (
616619 return_span,
617- impl_m_hir_id ,
620+ impl_m_def_id ,
618621 ObligationCauseCode :: CompareImplItemObligation {
619- impl_item_def_id : impl_m . def_id . expect_local ( ) ,
622+ impl_item_def_id : impl_m_def_id ,
620623 trait_item_def_id : trait_m. def_id ,
621624 kind : impl_m. kind ,
622625 } ,
@@ -633,7 +636,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
633636 let ocx = ObligationCtxt :: new ( infcx) ;
634637
635638 // Normalize the impl signature with fresh variables for lifetime inference.
636- let norm_cause = ObligationCause :: misc ( return_span, impl_m_hir_id ) ;
639+ let norm_cause = ObligationCause :: misc ( return_span, impl_m_def_id ) ;
637640 let impl_sig = ocx. normalize (
638641 & norm_cause,
639642 param_env,
@@ -650,7 +653,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
650653 // the ImplTraitInTraitCollector, which gathers all of the RPITITs and replaces
651654 // them with inference variables.
652655 // We will use these inference variables to collect the hidden types of RPITITs.
653- let mut collector = ImplTraitInTraitCollector :: new ( & ocx, return_span, param_env, impl_m_hir_id ) ;
656+ let mut collector = ImplTraitInTraitCollector :: new ( & ocx, return_span, param_env, impl_m_def_id ) ;
654657 let unnormalized_trait_sig = tcx
655658 . liberate_late_bound_regions (
656659 impl_m. def_id ,
@@ -732,12 +735,11 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
732735 let outlives_environment = OutlivesEnvironment :: with_bounds (
733736 param_env,
734737 Some ( infcx) ,
735- infcx. implied_bounds_tys ( param_env, impl_m_hir_id , wf_tys) ,
738+ infcx. implied_bounds_tys ( param_env, impl_m_def_id , wf_tys) ,
736739 ) ;
737- infcx. err_ctxt ( ) . check_region_obligations_and_report_errors (
738- impl_m. def_id . expect_local ( ) ,
739- & outlives_environment,
740- ) ?;
740+ infcx
741+ . err_ctxt ( )
742+ . check_region_obligations_and_report_errors ( impl_m_def_id, & outlives_environment) ?;
741743
742744 let mut collected_tys = FxHashMap :: default ( ) ;
743745 for ( def_id, ( ty, substs) ) in collector. types {
@@ -819,15 +821,15 @@ struct ImplTraitInTraitCollector<'a, 'tcx> {
819821 types : FxHashMap < DefId , ( Ty < ' tcx > , ty:: SubstsRef < ' tcx > ) > ,
820822 span : Span ,
821823 param_env : ty:: ParamEnv < ' tcx > ,
822- body_id : hir :: HirId ,
824+ body_id : LocalDefId ,
823825}
824826
825827impl < ' a , ' tcx > ImplTraitInTraitCollector < ' a , ' tcx > {
826828 fn new (
827829 ocx : & ' a ObligationCtxt < ' a , ' tcx > ,
828830 span : Span ,
829831 param_env : ty:: ParamEnv < ' tcx > ,
830- body_id : hir :: HirId ,
832+ body_id : LocalDefId ,
831833 ) -> Self {
832834 ImplTraitInTraitCollector { ocx, types : FxHashMap :: default ( ) , span, param_env, body_id }
833835 }
@@ -1671,14 +1673,12 @@ pub(super) fn compare_impl_const_raw(
16711673
16721674 // Create a parameter environment that represents the implementation's
16731675 // method.
1674- let impl_c_hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( impl_const_item_def) ;
1675-
16761676 // Compute placeholder form of impl and trait const tys.
16771677 let impl_ty = tcx. type_of ( impl_const_item_def. to_def_id ( ) ) ;
16781678 let trait_ty = tcx. bound_type_of ( trait_const_item_def) . subst ( tcx, trait_to_impl_substs) ;
16791679 let mut cause = ObligationCause :: new (
16801680 impl_c_span,
1681- impl_c_hir_id ,
1681+ impl_const_item_def ,
16821682 ObligationCauseCode :: CompareImplItemObligation {
16831683 impl_item_def_id : impl_const_item_def,
16841684 trait_item_def_id : trait_const_item_def,
@@ -1799,7 +1799,7 @@ fn compare_type_predicate_entailment<'tcx>(
17991799 // This `HirId` should be used for the `body_id` field on each
18001800 // `ObligationCause` (and the `FnCtxt`). This is what
18011801 // `regionck_item` expects.
1802- let impl_ty_hir_id = tcx . hir ( ) . local_def_id_to_hir_id ( impl_ty. def_id . expect_local ( ) ) ;
1802+ let impl_ty_def_id = impl_ty. def_id . expect_local ( ) ;
18031803 debug ! ( "compare_type_predicate_entailment: trait_to_impl_substs={:?}" , trait_to_impl_substs) ;
18041804
18051805 // The predicates declared by the impl definition, the trait and the
@@ -1814,7 +1814,7 @@ fn compare_type_predicate_entailment<'tcx>(
18141814
18151815 debug ! ( "compare_type_predicate_entailment: bounds={:?}" , hybrid_preds) ;
18161816
1817- let normalize_cause = traits:: ObligationCause :: misc ( impl_ty_span, impl_ty_hir_id ) ;
1817+ let normalize_cause = traits:: ObligationCause :: misc ( impl_ty_span, impl_ty_def_id ) ;
18181818 let param_env = ty:: ParamEnv :: new (
18191819 tcx. intern_predicates ( & hybrid_preds. predicates ) ,
18201820 Reveal :: UserFacing ,
@@ -1827,12 +1827,12 @@ fn compare_type_predicate_entailment<'tcx>(
18271827 debug ! ( "compare_type_predicate_entailment: caller_bounds={:?}" , param_env. caller_bounds( ) ) ;
18281828
18291829 for ( predicate, span) in impl_ty_own_bounds {
1830- let cause = ObligationCause :: misc ( span, impl_ty_hir_id ) ;
1830+ let cause = ObligationCause :: misc ( span, impl_ty_def_id ) ;
18311831 let predicate = ocx. normalize ( & cause, param_env, predicate) ;
18321832
18331833 let cause = ObligationCause :: new (
18341834 span,
1835- impl_ty_hir_id ,
1835+ impl_ty_def_id ,
18361836 ObligationCauseCode :: CompareImplItemObligation {
18371837 impl_item_def_id : impl_ty. def_id . expect_local ( ) ,
18381838 trait_item_def_id : trait_ty. def_id ,
@@ -2008,7 +2008,7 @@ pub(super) fn check_type_bounds<'tcx>(
20082008 } ;
20092009 debug ! ( ?normalize_param_env) ;
20102010
2011- let impl_ty_hir_id = tcx . hir ( ) . local_def_id_to_hir_id ( impl_ty. def_id . expect_local ( ) ) ;
2011+ let impl_ty_def_id = impl_ty. def_id . expect_local ( ) ;
20122012 let impl_ty_substs = InternalSubsts :: identity_for_item ( tcx, impl_ty. def_id ) ;
20132013 let rebased_substs = impl_ty_substs. rebase_onto ( tcx, container_id, impl_trait_ref. substs ) ;
20142014
@@ -2020,7 +2020,7 @@ pub(super) fn check_type_bounds<'tcx>(
20202020
20212021 let normalize_cause = ObligationCause :: new (
20222022 impl_ty_span,
2023- impl_ty_hir_id ,
2023+ impl_ty_def_id ,
20242024 ObligationCauseCode :: CheckAssociatedTypeBounds {
20252025 impl_item_def_id : impl_ty. def_id . expect_local ( ) ,
20262026 trait_item_def_id : trait_ty. def_id ,
@@ -2032,7 +2032,7 @@ pub(super) fn check_type_bounds<'tcx>(
20322032 } else {
20332033 traits:: BindingObligation ( trait_ty. def_id , span)
20342034 } ;
2035- ObligationCause :: new ( impl_ty_span, impl_ty_hir_id , code)
2035+ ObligationCause :: new ( impl_ty_span, impl_ty_def_id , code)
20362036 } ;
20372037
20382038 let obligations = tcx
@@ -2063,7 +2063,7 @@ pub(super) fn check_type_bounds<'tcx>(
20632063
20642064 // Finally, resolve all regions. This catches wily misuses of
20652065 // lifetime parameters.
2066- let implied_bounds = infcx. implied_bounds_tys ( param_env, impl_ty_hir_id , assumed_wf_types) ;
2066+ let implied_bounds = infcx. implied_bounds_tys ( param_env, impl_ty_def_id , assumed_wf_types) ;
20672067 let outlives_environment =
20682068 OutlivesEnvironment :: with_bounds ( param_env, Some ( & infcx) , implied_bounds) ;
20692069
0 commit comments