From 3f2dd4d24a1fae4a985ab360028b42ca1e9c61e9 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 3 May 2017 13:23:41 -0400 Subject: [PATCH] remove `ast_ty_to_ty_cache` entirely --- src/librustc/ty/context.rs | 4 ---- src/librustc_typeck/astconv.rs | 13 +------------ src/librustc_typeck/check/mod.rs | 7 ------- src/librustc_typeck/check/writeback.rs | 8 -------- src/librustc_typeck/collect.rs | 7 +------ 5 files changed, 2 insertions(+), 37 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 6de61013dfd..34c9b2d5cd3 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -556,9 +556,6 @@ pub struct GlobalCtxt<'tcx> { /// error reporting, and so is lazily initialised and generally /// shouldn't taint the common path (hence the RefCell). pub all_traits: RefCell>>, - - /// HIR Ty -> Ty lowering cache. - pub ast_ty_to_ty_cache: RefCell>>, } impl<'tcx> GlobalCtxt<'tcx> { @@ -770,7 +767,6 @@ pub fn create_and_enter(s: &'tcx Session, derive_macros: RefCell::new(NodeMap()), stability_interner: RefCell::new(FxHashSet()), all_traits: RefCell::new(None), - ast_ty_to_ty_cache: RefCell::new(NodeMap()), }, f) } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index c89e3ca8b68..33b0aa3dbff 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -25,9 +25,8 @@ use rustc_back::slice; use require_c_abi_if_variadic; use util::common::{ErrorReported, FN_OUTPUT_NAME}; -use util::nodemap::{NodeMap, FxHashSet}; +use util::nodemap::FxHashSet; -use std::cell::RefCell; use std::iter; use syntax::{abi, ast}; use syntax::feature_gate::{GateIssue, emit_feature_err}; @@ -37,9 +36,6 @@ pub trait AstConv<'gcx, 'tcx> { fn tcx<'a>(&'a self) -> TyCtxt<'a, 'gcx, 'tcx>; - /// A cache used for the result of `ast_ty_to_ty_cache` - fn ast_ty_to_ty_cache(&self) -> &RefCell>>; - /// Returns the set of bounds in scope for the type parameter with /// the given id. fn get_type_parameter_bounds(&self, span: Span, def_id: DefId) @@ -1074,11 +1070,6 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> { let tcx = self.tcx(); - let cache = self.ast_ty_to_ty_cache(); - if let Some(ty) = cache.borrow().get(&ast_ty.id) { - return ty; - } - let result_ty = match ast_ty.node { hir::TySlice(ref ty) => { tcx.mk_slice(self.ast_ty_to_ty(&ty)) @@ -1240,8 +1231,6 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> { } }; - cache.borrow_mut().insert(ast_ty.id, result_ty); - result_ty } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index c401ed428e4..e949e677090 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -451,8 +451,6 @@ fn find_breakable(&mut self, target_id: ast::NodeId) -> &mut BreakableCtxt<'gcx, } pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - ast_ty_to_ty_cache: RefCell>>, - body_id: ast::NodeId, // Number of errors that had been reported when we started @@ -1516,10 +1514,6 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.tcx } - fn ast_ty_to_ty_cache(&self) -> &RefCell>> { - &self.ast_ty_to_ty_cache - } - fn get_free_substs(&self) -> Option<&Substs<'tcx>> { Some(&self.parameter_environment.free_substs) } @@ -1621,7 +1615,6 @@ pub fn new(inh: &'a Inherited<'a, 'gcx, 'tcx>, body_id: ast::NodeId) -> FnCtxt<'a, 'gcx, 'tcx> { FnCtxt { - ast_ty_to_ty_cache: RefCell::new(NodeMap()), body_id: body_id, err_count_on_creation: inh.tcx.sess.err_count(), ret_coercion: None, diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index ab2151544fc..49440037af5 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -43,7 +43,6 @@ pub fn resolve_type_vars_in_body(&self, body: &'gcx hir::Body) wbcx.visit_liberated_fn_sigs(); wbcx.visit_fru_field_types(); wbcx.visit_anon_types(); - wbcx.visit_type_nodes(); wbcx.visit_cast_types(); wbcx.visit_lints(); wbcx.visit_free_region_map(); @@ -442,13 +441,6 @@ fn visit_fru_field_types(&mut self) { } } - fn visit_type_nodes(&self) { - for (&id, ty) in self.fcx.ast_ty_to_ty_cache.borrow().iter() { - let ty = self.resolve(ty, &id); - self.fcx.tcx.ast_ty_to_ty_cache.borrow_mut().insert(id, ty); - } - } - fn resolve(&self, x: &T, span: &Locatable) -> T::Lifted where T: TypeFoldable<'tcx> + ty::Lift<'gcx> { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 7d1a6894a82..f44f74830cb 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -64,11 +64,10 @@ use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt}; use rustc::ty::maps::Providers; use rustc::ty::util::IntTypeExt; -use util::nodemap::{NodeMap, FxHashMap}; +use util::nodemap::FxHashMap; use rustc_const_math::ConstInt; -use std::cell::RefCell; use std::collections::BTreeMap; use syntax::{abi, ast}; @@ -198,10 +197,6 @@ pub fn to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> { impl<'a, 'tcx> AstConv<'tcx, 'tcx> for ItemCtxt<'a, 'tcx> { fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { self.tcx } - fn ast_ty_to_ty_cache(&self) -> &RefCell>> { - &self.tcx.ast_ty_to_ty_cache - } - fn get_type_parameter_bounds(&self, span: Span, def_id: DefId)