From 06b2e659d3b7784b041a332920ae8630eaf954fd Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Thu, 21 Oct 2021 19:22:44 +0200 Subject: [PATCH] Remove unused root_parent. --- compiler/rustc_middle/src/middle/region.rs | 16 ++++------------ compiler/rustc_passes/src/region.rs | 14 +------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/compiler/rustc_middle/src/middle/region.rs b/compiler/rustc_middle/src/middle/region.rs index 605e0bc2e63..39ca41c92ff 100644 --- a/compiler/rustc_middle/src/middle/region.rs +++ b/compiler/rustc_middle/src/middle/region.rs @@ -7,13 +7,12 @@ //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html use crate::ty::TyCtxt; -use rustc_hir as hir; -use rustc_hir::Node; -use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext}; - use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_hir as hir; +use rustc_hir::Node; use rustc_macros::HashStable; +use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext}; use rustc_span::{Span, DUMMY_SP}; use std::fmt; @@ -210,11 +209,6 @@ pub struct ScopeTree { /// If not empty, this body is the root of this region hierarchy. pub root_body: Option, - /// The parent of the root body owner, if the latter is an - /// an associated const or method, as impls/traits can also - /// have lifetime parameters free in this body. - pub root_parent: Option, - /// Maps from a scope ID to the enclosing scope id; /// this is usually corresponding to the lexical nesting, though /// in the case of closures the parent scope is the innermost @@ -445,7 +439,6 @@ impl<'a> HashStable> for ScopeTree { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { let ScopeTree { root_body, - root_parent, ref body_expr_count, ref parent_map, ref var_map, @@ -455,8 +448,7 @@ impl<'a> HashStable> for ScopeTree { } = *self; hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| { - root_body.hash_stable(hcx, hasher); - root_parent.hash_stable(hcx, hasher); + root_body.hash_stable(hcx, hasher) }); body_expr_count.hash_stable(hcx, hasher); diff --git a/compiler/rustc_passes/src/region.rs b/compiler/rustc_passes/src/region.rs index 6a8feb041da..ae423070392 100644 --- a/compiler/rustc_passes/src/region.rs +++ b/compiler/rustc_passes/src/region.rs @@ -11,7 +11,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; -use rustc_hir::{Arm, Block, Expr, Local, Node, Pat, PatKind, Stmt}; +use rustc_hir::{Arm, Block, Expr, Local, Pat, PatKind, Stmt}; use rustc_index::vec::Idx; use rustc_middle::middle::region::*; use rustc_middle::ty::query::Providers; @@ -837,19 +837,7 @@ fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree { let body = tcx.hir().body(body_id); visitor.scope_tree.root_body = Some(body.value.hir_id); - - // If the item is an associated const or a method, - // record its impl/trait parent, as it can also have - // lifetime parameters free in this body. - match tcx.hir().get(id) { - Node::ImplItem(_) | Node::TraitItem(_) => { - visitor.scope_tree.root_parent = Some(tcx.hir().get_parent_item(id)); - } - _ => {} - } - visitor.visit_body(body); - visitor.scope_tree } else { ScopeTree::default()