diff options
| author | ljedrz <ljedrz@gmail.com> | 2019-03-01 10:28:13 +0100 |
|---|---|---|
| committer | ljedrz <ljedrz@gmail.com> | 2019-03-02 07:48:53 +0100 |
| commit | fa61c67fe63df1d69979f116a29bb72ade0c6308 (patch) | |
| tree | 99c5495c4fa1a05d820e3475422263e9a5267894 /src/librustc/ty | |
| parent | fb22315f0878b432e1e79f9825a4b94651a5d475 (diff) | |
| download | rust-fa61c67fe63df1d69979f116a29bb72ade0c6308.tar.gz rust-fa61c67fe63df1d69979f116a29bb72ade0c6308.zip | |
hir: HirIdify Impl&TraitItemId
Diffstat (limited to 'src/librustc/ty')
| -rw-r--r-- | src/librustc/ty/mod.rs | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 3b89f853c3e..1f897d29a1e 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2727,7 +2727,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { parent_vis: &hir::Visibility, trait_item_ref: &hir::TraitItemRef) -> AssociatedItem { - let def_id = self.hir().local_def_id(trait_item_ref.id.node_id); + let def_id = self.hir().local_def_id_from_hir_id(trait_item_ref.id.hir_id); let (kind, has_self) = match trait_item_ref.kind { hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false), hir::AssociatedItemKind::Method { has_self } => { @@ -2737,13 +2737,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { hir::AssociatedItemKind::Existential => bug!("only impls can have existentials"), }; - let hir_id = self.hir().node_to_hir_id(trait_item_ref.id.node_id); - AssociatedItem { ident: trait_item_ref.ident, kind, // Visibility of trait items is inherited from their traits. - vis: Visibility::from_hir(parent_vis, hir_id, self), + vis: Visibility::from_hir(parent_vis, trait_item_ref.id.hir_id, self), defaultness: trait_item_ref.defaultness, def_id, container: TraitContainer(parent_def_id), @@ -2755,7 +2753,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { parent_def_id: DefId, impl_item_ref: &hir::ImplItemRef) -> AssociatedItem { - let def_id = self.hir().local_def_id(impl_item_ref.id.node_id); + let def_id = self.hir().local_def_id_from_hir_id(impl_item_ref.id.hir_id); let (kind, has_self) = match impl_item_ref.kind { hir::AssociatedItemKind::Const => (ty::AssociatedKind::Const, false), hir::AssociatedItemKind::Method { has_self } => { @@ -2765,13 +2763,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { hir::AssociatedItemKind::Existential => (ty::AssociatedKind::Existential, false), }; - let hir_id = self.hir().node_to_hir_id(impl_item_ref.id.node_id); - AssociatedItem { ident: impl_item_ref.ident, kind, // Visibility of trait impl items doesn't matter. - vis: ty::Visibility::from_hir(&impl_item_ref.vis, hir_id, self), + vis: ty::Visibility::from_hir(&impl_item_ref.vis, impl_item_ref.id.hir_id, self), defaultness: impl_item_ref.defaultness, def_id, container: ImplContainer(parent_def_id), @@ -3041,13 +3037,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> AssociatedItem { - let id = tcx.hir().as_local_node_id(def_id).unwrap(); - let parent_id = tcx.hir().get_parent(id); - let parent_def_id = tcx.hir().local_def_id(parent_id); - let parent_item = tcx.hir().expect_item(parent_id); + let id = tcx.hir().as_local_hir_id(def_id).unwrap(); + let parent_id = tcx.hir().get_parent_item(id); + let parent_def_id = tcx.hir().local_def_id_from_hir_id(parent_id); + let parent_item = tcx.hir().expect_item_by_hir_id(parent_id); match parent_item.node { hir::ItemKind::Impl(.., ref impl_item_refs) => { - if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.node_id == id) { + if let Some(impl_item_ref) = impl_item_refs.iter().find(|i| i.id.hir_id == id) { let assoc_item = tcx.associated_item_from_impl_item_ref(parent_def_id, impl_item_ref); 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 } hir::ItemKind::Trait(.., ref trait_item_refs) => { - if let Some(trait_item_ref) = trait_item_refs.iter().find(|i| i.id.node_id == id) { + if let Some(trait_item_ref) = trait_item_refs.iter().find(|i| i.id.hir_id == id) { let assoc_item = tcx.associated_item_from_trait_item_ref(parent_def_id, &parent_item.vis, trait_item_ref); @@ -3110,13 +3106,13 @@ fn associated_item_def_ids<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir::ItemKind::Trait(.., ref trait_item_refs) => { trait_item_refs.iter() .map(|trait_item_ref| trait_item_ref.id) - .map(|id| tcx.hir().local_def_id(id.node_id)) + .map(|id| tcx.hir().local_def_id_from_hir_id(id.hir_id)) .collect() } hir::ItemKind::Impl(.., ref impl_item_refs) => { impl_item_refs.iter() .map(|impl_item_ref| impl_item_ref.id) - .map(|id| tcx.hir().local_def_id(id.node_id)) + .map(|id| tcx.hir().local_def_id_from_hir_id(id.hir_id)) .collect() } hir::ItemKind::TraitAlias(..) => vec![], |
