From 2d341e1e288cfb39cf7e8644c468654a9b8e0fca Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Wed, 3 Mar 2021 21:46:09 +0100 Subject: [PATCH] Remove parent_node. --- compiler/rustc_middle/src/hir/map/mod.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 1148c587c4d0..973707c59fa6 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -30,15 +30,6 @@ pub struct Entry<'hir> { node: Node<'hir>, } -impl<'hir> Entry<'hir> { - fn parent_node(self) -> Option { - match self.node { - Node::Crate(_) => None, - _ => Some(self.parent), - } - } -} - fn fn_decl<'hir>(node: Node<'hir>) -> Option<&'hir FnDecl<'hir>> { match node { Node::Item(Item { kind: ItemKind::Fn(sig, _, _), .. }) @@ -529,7 +520,7 @@ impl<'hir> Map<'hir> { /// from a node to the root of the HIR (unless you get back the same ID here, /// which can happen if the ID is not in the map itself or is just weird). pub fn get_parent_node(&self, hir_id: HirId) -> HirId { - self.get_entry(hir_id).parent_node().unwrap_or(hir_id) + self.get_entry(hir_id).parent } /// Returns an iterator for the nodes in the ancestor tree of the `current_id`