@@ -147,12 +147,12 @@ fn compare_method_predicate_entailment<'tcx>(
147
147
//
148
148
// FIXME(@lcnr): remove that after removing `cause.body_id` from
149
149
// 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 ( ) ;
151
151
let cause = ObligationCause :: new (
152
152
impl_m_span,
153
- impl_m_hir_id ,
153
+ impl_m_def_id ,
154
154
ObligationCauseCode :: CompareImplItemObligation {
155
- impl_item_def_id : impl_m . def_id . expect_local ( ) ,
155
+ impl_item_def_id : impl_m_def_id ,
156
156
trait_item_def_id : trait_m. def_id ,
157
157
kind : impl_m. kind ,
158
158
} ,
@@ -198,7 +198,7 @@ fn compare_method_predicate_entailment<'tcx>(
198
198
// Construct trait parameter environment and then shift it into the placeholder viewpoint.
199
199
// The key step here is to update the caller_bounds's predicates to be
200
200
// 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 ) ;
202
202
let param_env = ty:: ParamEnv :: new (
203
203
tcx. intern_predicates ( & hybrid_preds. predicates ) ,
204
204
Reveal :: UserFacing ,
@@ -213,14 +213,14 @@ fn compare_method_predicate_entailment<'tcx>(
213
213
214
214
let impl_m_own_bounds = impl_m_predicates. instantiate_own ( tcx, impl_to_placeholder_substs) ;
215
215
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 ) ;
217
217
let predicate = ocx. normalize ( & normalize_cause, param_env, predicate) ;
218
218
219
219
let cause = ObligationCause :: new (
220
220
span,
221
- impl_m_hir_id ,
221
+ impl_m_def_id ,
222
222
ObligationCauseCode :: CompareImplItemObligation {
223
- impl_item_def_id : impl_m . def_id . expect_local ( ) ,
223
+ impl_item_def_id : impl_m_def_id ,
224
224
trait_item_def_id : trait_m. def_id ,
225
225
kind : impl_m. kind ,
226
226
} ,
@@ -253,7 +253,7 @@ fn compare_method_predicate_entailment<'tcx>(
253
253
) ;
254
254
let unnormalized_impl_fty = tcx. mk_fn_ptr ( ty:: Binder :: dummy ( unnormalized_impl_sig) ) ;
255
255
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 ) ;
257
257
let impl_sig = ocx. normalize ( & norm_cause, param_env, unnormalized_impl_sig) ;
258
258
debug ! ( "compare_impl_method: impl_fty={:?}" , impl_sig) ;
259
259
@@ -311,6 +311,7 @@ fn compare_method_predicate_entailment<'tcx>(
311
311
if !errors. is_empty ( ) {
312
312
match check_implied_wf {
313
313
CheckImpliedWfMode :: Check => {
314
+ let impl_m_hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( impl_m_def_id) ;
314
315
return compare_method_predicate_entailment (
315
316
tcx,
316
317
impl_m,
@@ -336,7 +337,7 @@ fn compare_method_predicate_entailment<'tcx>(
336
337
let outlives_env = OutlivesEnvironment :: with_bounds (
337
338
param_env,
338
339
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 ( ) ) ,
340
341
) ;
341
342
infcx. process_registered_region_obligations (
342
343
outlives_env. region_bound_pairs ( ) ,
@@ -346,6 +347,7 @@ fn compare_method_predicate_entailment<'tcx>(
346
347
if !errors. is_empty ( ) {
347
348
// FIXME(compiler-errors): This can be simplified when IMPLIED_BOUNDS_ENTAILMENT
348
349
// 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) ;
349
351
match check_implied_wf {
350
352
CheckImpliedWfMode :: Check => {
351
353
return compare_method_predicate_entailment (
@@ -371,7 +373,7 @@ fn compare_method_predicate_entailment<'tcx>(
371
373
}
372
374
CheckImpliedWfMode :: Skip => {
373
375
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) ;
375
377
}
376
378
return Err ( tcx
377
379
. sess
@@ -610,13 +612,14 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
610
612
611
613
let trait_to_impl_substs = impl_trait_ref. substs ;
612
614
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) ;
614
617
let return_span = tcx. hir ( ) . fn_decl_by_hir_id ( impl_m_hir_id) . unwrap ( ) . output . span ( ) ;
615
618
let cause = ObligationCause :: new (
616
619
return_span,
617
- impl_m_hir_id ,
620
+ impl_m_def_id ,
618
621
ObligationCauseCode :: CompareImplItemObligation {
619
- impl_item_def_id : impl_m . def_id . expect_local ( ) ,
622
+ impl_item_def_id : impl_m_def_id ,
620
623
trait_item_def_id : trait_m. def_id ,
621
624
kind : impl_m. kind ,
622
625
} ,
@@ -633,7 +636,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
633
636
let ocx = ObligationCtxt :: new ( infcx) ;
634
637
635
638
// 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 ) ;
637
640
let impl_sig = ocx. normalize (
638
641
& norm_cause,
639
642
param_env,
@@ -650,7 +653,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
650
653
// the ImplTraitInTraitCollector, which gathers all of the RPITITs and replaces
651
654
// them with inference variables.
652
655
// 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 ) ;
654
657
let unnormalized_trait_sig = tcx
655
658
. liberate_late_bound_regions (
656
659
impl_m. def_id ,
@@ -732,12 +735,11 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
732
735
let outlives_environment = OutlivesEnvironment :: with_bounds (
733
736
param_env,
734
737
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) ,
736
739
) ;
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) ?;
741
743
742
744
let mut collected_tys = FxHashMap :: default ( ) ;
743
745
for ( def_id, ( ty, substs) ) in collector. types {
@@ -819,15 +821,15 @@ struct ImplTraitInTraitCollector<'a, 'tcx> {
819
821
types : FxHashMap < DefId , ( Ty < ' tcx > , ty:: SubstsRef < ' tcx > ) > ,
820
822
span : Span ,
821
823
param_env : ty:: ParamEnv < ' tcx > ,
822
- body_id : hir :: HirId ,
824
+ body_id : LocalDefId ,
823
825
}
824
826
825
827
impl < ' a , ' tcx > ImplTraitInTraitCollector < ' a , ' tcx > {
826
828
fn new (
827
829
ocx : & ' a ObligationCtxt < ' a , ' tcx > ,
828
830
span : Span ,
829
831
param_env : ty:: ParamEnv < ' tcx > ,
830
- body_id : hir :: HirId ,
832
+ body_id : LocalDefId ,
831
833
) -> Self {
832
834
ImplTraitInTraitCollector { ocx, types : FxHashMap :: default ( ) , span, param_env, body_id }
833
835
}
@@ -1671,14 +1673,12 @@ pub(super) fn compare_impl_const_raw(
1671
1673
1672
1674
// Create a parameter environment that represents the implementation's
1673
1675
// method.
1674
- let impl_c_hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( impl_const_item_def) ;
1675
-
1676
1676
// Compute placeholder form of impl and trait const tys.
1677
1677
let impl_ty = tcx. type_of ( impl_const_item_def. to_def_id ( ) ) ;
1678
1678
let trait_ty = tcx. bound_type_of ( trait_const_item_def) . subst ( tcx, trait_to_impl_substs) ;
1679
1679
let mut cause = ObligationCause :: new (
1680
1680
impl_c_span,
1681
- impl_c_hir_id ,
1681
+ impl_const_item_def ,
1682
1682
ObligationCauseCode :: CompareImplItemObligation {
1683
1683
impl_item_def_id : impl_const_item_def,
1684
1684
trait_item_def_id : trait_const_item_def,
@@ -1799,7 +1799,7 @@ fn compare_type_predicate_entailment<'tcx>(
1799
1799
// This `HirId` should be used for the `body_id` field on each
1800
1800
// `ObligationCause` (and the `FnCtxt`). This is what
1801
1801
// `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 ( ) ;
1803
1803
debug ! ( "compare_type_predicate_entailment: trait_to_impl_substs={:?}" , trait_to_impl_substs) ;
1804
1804
1805
1805
// The predicates declared by the impl definition, the trait and the
@@ -1814,7 +1814,7 @@ fn compare_type_predicate_entailment<'tcx>(
1814
1814
1815
1815
debug ! ( "compare_type_predicate_entailment: bounds={:?}" , hybrid_preds) ;
1816
1816
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 ) ;
1818
1818
let param_env = ty:: ParamEnv :: new (
1819
1819
tcx. intern_predicates ( & hybrid_preds. predicates ) ,
1820
1820
Reveal :: UserFacing ,
@@ -1827,12 +1827,12 @@ fn compare_type_predicate_entailment<'tcx>(
1827
1827
debug ! ( "compare_type_predicate_entailment: caller_bounds={:?}" , param_env. caller_bounds( ) ) ;
1828
1828
1829
1829
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 ) ;
1831
1831
let predicate = ocx. normalize ( & cause, param_env, predicate) ;
1832
1832
1833
1833
let cause = ObligationCause :: new (
1834
1834
span,
1835
- impl_ty_hir_id ,
1835
+ impl_ty_def_id ,
1836
1836
ObligationCauseCode :: CompareImplItemObligation {
1837
1837
impl_item_def_id : impl_ty. def_id . expect_local ( ) ,
1838
1838
trait_item_def_id : trait_ty. def_id ,
@@ -2008,7 +2008,7 @@ pub(super) fn check_type_bounds<'tcx>(
2008
2008
} ;
2009
2009
debug ! ( ?normalize_param_env) ;
2010
2010
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 ( ) ;
2012
2012
let impl_ty_substs = InternalSubsts :: identity_for_item ( tcx, impl_ty. def_id ) ;
2013
2013
let rebased_substs = impl_ty_substs. rebase_onto ( tcx, container_id, impl_trait_ref. substs ) ;
2014
2014
@@ -2020,7 +2020,7 @@ pub(super) fn check_type_bounds<'tcx>(
2020
2020
2021
2021
let normalize_cause = ObligationCause :: new (
2022
2022
impl_ty_span,
2023
- impl_ty_hir_id ,
2023
+ impl_ty_def_id ,
2024
2024
ObligationCauseCode :: CheckAssociatedTypeBounds {
2025
2025
impl_item_def_id : impl_ty. def_id . expect_local ( ) ,
2026
2026
trait_item_def_id : trait_ty. def_id ,
@@ -2032,7 +2032,7 @@ pub(super) fn check_type_bounds<'tcx>(
2032
2032
} else {
2033
2033
traits:: BindingObligation ( trait_ty. def_id , span)
2034
2034
} ;
2035
- ObligationCause :: new ( impl_ty_span, impl_ty_hir_id , code)
2035
+ ObligationCause :: new ( impl_ty_span, impl_ty_def_id , code)
2036
2036
} ;
2037
2037
2038
2038
let obligations = tcx
@@ -2063,7 +2063,7 @@ pub(super) fn check_type_bounds<'tcx>(
2063
2063
2064
2064
// Finally, resolve all regions. This catches wily misuses of
2065
2065
// 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) ;
2067
2067
let outlives_environment =
2068
2068
OutlivesEnvironment :: with_bounds ( param_env, Some ( & infcx) , implied_bounds) ;
2069
2069
0 commit comments