@@ -2727,7 +2727,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2727
2727
parent_vis : & hir:: Visibility ,
2728
2728
trait_item_ref : & hir:: TraitItemRef )
2729
2729
-> AssociatedItem {
2730
- let def_id = self . hir ( ) . local_def_id ( trait_item_ref. id . node_id ) ;
2730
+ let def_id = self . hir ( ) . local_def_id_from_hir_id ( trait_item_ref. id . hir_id ) ;
2731
2731
let ( kind, has_self) = match trait_item_ref. kind {
2732
2732
hir:: AssociatedItemKind :: Const => ( ty:: AssociatedKind :: Const , false ) ,
2733
2733
hir:: AssociatedItemKind :: Method { has_self } => {
@@ -2737,13 +2737,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2737
2737
hir:: AssociatedItemKind :: Existential => bug ! ( "only impls can have existentials" ) ,
2738
2738
} ;
2739
2739
2740
- let hir_id = self . hir ( ) . node_to_hir_id ( trait_item_ref. id . node_id ) ;
2741
-
2742
2740
AssociatedItem {
2743
2741
ident : trait_item_ref. ident ,
2744
2742
kind,
2745
2743
// Visibility of trait items is inherited from their traits.
2746
- vis : Visibility :: from_hir ( parent_vis, hir_id, self ) ,
2744
+ vis : Visibility :: from_hir ( parent_vis, trait_item_ref . id . hir_id , self ) ,
2747
2745
defaultness : trait_item_ref. defaultness ,
2748
2746
def_id,
2749
2747
container : TraitContainer ( parent_def_id) ,
@@ -2755,7 +2753,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2755
2753
parent_def_id : DefId ,
2756
2754
impl_item_ref : & hir:: ImplItemRef )
2757
2755
-> AssociatedItem {
2758
- let def_id = self . hir ( ) . local_def_id ( impl_item_ref. id . node_id ) ;
2756
+ let def_id = self . hir ( ) . local_def_id_from_hir_id ( impl_item_ref. id . hir_id ) ;
2759
2757
let ( kind, has_self) = match impl_item_ref. kind {
2760
2758
hir:: AssociatedItemKind :: Const => ( ty:: AssociatedKind :: Const , false ) ,
2761
2759
hir:: AssociatedItemKind :: Method { has_self } => {
@@ -2765,13 +2763,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2765
2763
hir:: AssociatedItemKind :: Existential => ( ty:: AssociatedKind :: Existential , false ) ,
2766
2764
} ;
2767
2765
2768
- let hir_id = self . hir ( ) . node_to_hir_id ( impl_item_ref. id . node_id ) ;
2769
-
2770
2766
AssociatedItem {
2771
2767
ident : impl_item_ref. ident ,
2772
2768
kind,
2773
2769
// Visibility of trait impl items doesn't matter.
2774
- vis : ty:: Visibility :: from_hir ( & impl_item_ref. vis , hir_id, self ) ,
2770
+ vis : ty:: Visibility :: from_hir ( & impl_item_ref. vis , impl_item_ref . id . hir_id , self ) ,
2775
2771
defaultness : impl_item_ref. defaultness ,
2776
2772
def_id,
2777
2773
container : ImplContainer ( parent_def_id) ,
@@ -3041,13 +3037,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
3041
3037
}
3042
3038
3043
3039
fn associated_item < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId ) -> AssociatedItem {
3044
- let id = tcx. hir ( ) . as_local_node_id ( def_id) . unwrap ( ) ;
3045
- let parent_id = tcx. hir ( ) . get_parent ( id) ;
3046
- let parent_def_id = tcx. hir ( ) . local_def_id ( parent_id) ;
3047
- let parent_item = tcx. hir ( ) . expect_item ( parent_id) ;
3040
+ let id = tcx. hir ( ) . as_local_hir_id ( def_id) . unwrap ( ) ;
3041
+ let parent_id = tcx. hir ( ) . get_parent_item ( id) ;
3042
+ let parent_def_id = tcx. hir ( ) . local_def_id_from_hir_id ( parent_id) ;
3043
+ let parent_item = tcx. hir ( ) . expect_item_by_hir_id ( parent_id) ;
3048
3044
match parent_item. node {
3049
3045
hir:: ItemKind :: Impl ( .., ref impl_item_refs) => {
3050
- if let Some ( impl_item_ref) = impl_item_refs. iter ( ) . find ( |i| i. id . node_id == id) {
3046
+ if let Some ( impl_item_ref) = impl_item_refs. iter ( ) . find ( |i| i. id . hir_id == id) {
3051
3047
let assoc_item = tcx. associated_item_from_impl_item_ref ( parent_def_id,
3052
3048
impl_item_ref) ;
3053
3049
debug_assert_eq ! ( assoc_item. def_id, def_id) ;
@@ -3056,7 +3052,7 @@ fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Asso
3056
3052
}
3057
3053
3058
3054
hir:: ItemKind :: Trait ( .., ref trait_item_refs) => {
3059
- if let Some ( trait_item_ref) = trait_item_refs. iter ( ) . find ( |i| i. id . node_id == id) {
3055
+ if let Some ( trait_item_ref) = trait_item_refs. iter ( ) . find ( |i| i. id . hir_id == id) {
3060
3056
let assoc_item = tcx. associated_item_from_trait_item_ref ( parent_def_id,
3061
3057
& parent_item. vis ,
3062
3058
trait_item_ref) ;
@@ -3110,13 +3106,13 @@ fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
3110
3106
hir:: ItemKind :: Trait ( .., ref trait_item_refs) => {
3111
3107
trait_item_refs. iter ( )
3112
3108
. map ( |trait_item_ref| trait_item_ref. id )
3113
- . map ( |id| tcx. hir ( ) . local_def_id ( id. node_id ) )
3109
+ . map ( |id| tcx. hir ( ) . local_def_id_from_hir_id ( id. hir_id ) )
3114
3110
. collect ( )
3115
3111
}
3116
3112
hir:: ItemKind :: Impl ( .., ref impl_item_refs) => {
3117
3113
impl_item_refs. iter ( )
3118
3114
. map ( |impl_item_ref| impl_item_ref. id )
3119
- . map ( |id| tcx. hir ( ) . local_def_id ( id. node_id ) )
3115
+ . map ( |id| tcx. hir ( ) . local_def_id_from_hir_id ( id. hir_id ) )
3120
3116
. collect ( )
3121
3117
}
3122
3118
hir:: ItemKind :: TraitAlias ( ..) => vec ! [ ] ,
0 commit comments