Skip to content

Commit 3f2dd4d

Browse files
committed
remove ast_ty_to_ty_cache entirely
1 parent 3039398 commit 3f2dd4d

File tree

5 files changed

+2
-37
lines changed

5 files changed

+2
-37
lines changed

Diff for: src/librustc/ty/context.rs

-4
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,6 @@ pub struct GlobalCtxt<'tcx> {
556556
/// error reporting, and so is lazily initialised and generally
557557
/// shouldn't taint the common path (hence the RefCell).
558558
pub all_traits: RefCell<Option<Vec<DefId>>>,
559-
560-
/// HIR Ty -> Ty lowering cache.
561-
pub ast_ty_to_ty_cache: RefCell<NodeMap<Ty<'tcx>>>,
562559
}
563560

564561
impl<'tcx> GlobalCtxt<'tcx> {
@@ -770,7 +767,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
770767
derive_macros: RefCell::new(NodeMap()),
771768
stability_interner: RefCell::new(FxHashSet()),
772769
all_traits: RefCell::new(None),
773-
ast_ty_to_ty_cache: RefCell::new(NodeMap()),
774770
}, f)
775771
}
776772

Diff for: src/librustc_typeck/astconv.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ use rustc::ty::wf::object_region_bounds;
2525
use rustc_back::slice;
2626
use require_c_abi_if_variadic;
2727
use util::common::{ErrorReported, FN_OUTPUT_NAME};
28-
use util::nodemap::{NodeMap, FxHashSet};
28+
use util::nodemap::FxHashSet;
2929

30-
use std::cell::RefCell;
3130
use std::iter;
3231
use syntax::{abi, ast};
3332
use syntax::feature_gate::{GateIssue, emit_feature_err};
@@ -37,9 +36,6 @@ use syntax_pos::Span;
3736
pub trait AstConv<'gcx, 'tcx> {
3837
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'gcx, 'tcx>;
3938

40-
/// A cache used for the result of `ast_ty_to_ty_cache`
41-
fn ast_ty_to_ty_cache(&self) -> &RefCell<NodeMap<Ty<'tcx>>>;
42-
4339
/// Returns the set of bounds in scope for the type parameter with
4440
/// the given id.
4541
fn get_type_parameter_bounds(&self, span: Span, def_id: DefId)
@@ -1074,11 +1070,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
10741070

10751071
let tcx = self.tcx();
10761072

1077-
let cache = self.ast_ty_to_ty_cache();
1078-
if let Some(ty) = cache.borrow().get(&ast_ty.id) {
1079-
return ty;
1080-
}
1081-
10821073
let result_ty = match ast_ty.node {
10831074
hir::TySlice(ref ty) => {
10841075
tcx.mk_slice(self.ast_ty_to_ty(&ty))
@@ -1240,8 +1231,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
12401231
}
12411232
};
12421233

1243-
cache.borrow_mut().insert(ast_ty.id, result_ty);
1244-
12451234
result_ty
12461235
}
12471236

Diff for: src/librustc_typeck/check/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,6 @@ impl<'gcx, 'tcx> EnclosingBreakables<'gcx, 'tcx> {
451451
}
452452

453453
pub struct FnCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
454-
ast_ty_to_ty_cache: RefCell<NodeMap<Ty<'tcx>>>,
455-
456454
body_id: ast::NodeId,
457455

458456
// 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>,
15161514
impl<'a, 'gcx, 'tcx> AstConv<'gcx, 'tcx> for FnCtxt<'a, 'gcx, 'tcx> {
15171515
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.tcx }
15181516

1519-
fn ast_ty_to_ty_cache(&self) -> &RefCell<NodeMap<Ty<'tcx>>> {
1520-
&self.ast_ty_to_ty_cache
1521-
}
1522-
15231517
fn get_free_substs(&self) -> Option<&Substs<'tcx>> {
15241518
Some(&self.parameter_environment.free_substs)
15251519
}
@@ -1621,7 +1615,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
16211615
body_id: ast::NodeId)
16221616
-> FnCtxt<'a, 'gcx, 'tcx> {
16231617
FnCtxt {
1624-
ast_ty_to_ty_cache: RefCell::new(NodeMap()),
16251618
body_id: body_id,
16261619
err_count_on_creation: inh.tcx.sess.err_count(),
16271620
ret_coercion: None,

Diff for: src/librustc_typeck/check/writeback.rs

-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
4343
wbcx.visit_liberated_fn_sigs();
4444
wbcx.visit_fru_field_types();
4545
wbcx.visit_anon_types();
46-
wbcx.visit_type_nodes();
4746
wbcx.visit_cast_types();
4847
wbcx.visit_lints();
4948
wbcx.visit_free_region_map();
@@ -442,13 +441,6 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
442441
}
443442
}
444443

445-
fn visit_type_nodes(&self) {
446-
for (&id, ty) in self.fcx.ast_ty_to_ty_cache.borrow().iter() {
447-
let ty = self.resolve(ty, &id);
448-
self.fcx.tcx.ast_ty_to_ty_cache.borrow_mut().insert(id, ty);
449-
}
450-
}
451-
452444
fn resolve<T>(&self, x: &T, span: &Locatable) -> T::Lifted
453445
where T: TypeFoldable<'tcx> + ty::Lift<'gcx>
454446
{

Diff for: src/librustc_typeck/collect.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ use rustc::ty::{ToPredicate, ReprOptions};
6464
use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt};
6565
use rustc::ty::maps::Providers;
6666
use rustc::ty::util::IntTypeExt;
67-
use util::nodemap::{NodeMap, FxHashMap};
67+
use util::nodemap::FxHashMap;
6868

6969
use rustc_const_math::ConstInt;
7070

71-
use std::cell::RefCell;
7271
use std::collections::BTreeMap;
7372

7473
use syntax::{abi, ast};
@@ -198,10 +197,6 @@ impl<'a,'tcx> ItemCtxt<'a,'tcx> {
198197
impl<'a, 'tcx> AstConv<'tcx, 'tcx> for ItemCtxt<'a, 'tcx> {
199198
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { self.tcx }
200199

201-
fn ast_ty_to_ty_cache(&self) -> &RefCell<NodeMap<Ty<'tcx>>> {
202-
&self.tcx.ast_ty_to_ty_cache
203-
}
204-
205200
fn get_type_parameter_bounds(&self,
206201
span: Span,
207202
def_id: DefId)

0 commit comments

Comments
 (0)