Skip to content

Commit 5f8eb66

Browse files
committed
---
yaml --- r: 94540 b: refs/heads/try c: 386300d h: refs/heads/master v: v3
1 parent 1d01124 commit 5f8eb66

File tree

6 files changed

+29
-15
lines changed

6 files changed

+29
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: fffbe7a8cdf2378a3c5617d1600cf2d31b7a357f
5+
refs/heads/try: 386300d4b0400aa0e9c8dfcca22a814599fa951e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/astencode.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,8 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
923923
}
924924

925925
{
926-
let r = tcx.node_type_substs.find(&id);
926+
let node_type_substs = tcx.node_type_substs.borrow();
927+
let r = node_type_substs.get().find(&id);
927928
for tys in r.iter() {
928929
ebml_w.tag(c::tag_table_node_type_subst, |ebml_w| {
929930
ebml_w.id(id);
@@ -1228,7 +1229,10 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
12281229
}
12291230
c::tag_table_node_type_subst => {
12301231
let tys = val_dsr.read_tys(xcx);
1231-
dcx.tcx.node_type_substs.insert(id, tys);
1232+
let mut node_type_substs = dcx.tcx
1233+
.node_type_substs
1234+
.borrow_mut();
1235+
node_type_substs.get().insert(id, tys);
12321236
}
12331237
c::tag_table_freevars => {
12341238
let fv_info = @val_dsr.read_to_vec(|val_dsr| {

branches/try/src/librustc/middle/kind.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ pub fn check_expr(cx: &mut Context, e: @Expr) {
264264
None => e.id,
265265
};
266266
{
267-
let r = cx.tcx.node_type_substs.find(&type_parameter_id);
267+
let node_type_substs = cx.tcx.node_type_substs.borrow();
268+
let r = node_type_substs.get().find(&type_parameter_id);
268269
for ts in r.iter() {
269270
let type_param_defs = match e.node {
270271
ExprPath(_) => {
@@ -326,7 +327,8 @@ pub fn check_expr(cx: &mut Context, e: @Expr) {
326327
fn check_ty(cx: &mut Context, aty: &Ty) {
327328
match aty.node {
328329
ty_path(_, _, id) => {
329-
let r = cx.tcx.node_type_substs.find(&id);
330+
let node_type_substs = cx.tcx.node_type_substs.borrow();
331+
let r = node_type_substs.get().find(&id);
330332
for ts in r.iter() {
331333
let did = ast_util::def_id_of_def(cx.tcx.def_map.get_copy(&id));
332334
let type_param_defs =

branches/try/src/librustc/middle/ty.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ struct ctxt_ {
284284
// of this node. This only applies to nodes that refer to entities
285285
// parameterized by type parameters, such as generic fns, types, or
286286
// other items.
287-
node_type_substs: @mut HashMap<NodeId, ~[t]>,
287+
node_type_substs: RefCell<HashMap<NodeId, ~[t]>>,
288288

289289
// Maps from a method to the method "descriptor"
290290
methods: @mut HashMap<DefId, @Method>,
@@ -985,7 +985,7 @@ pub fn mk_ctxt(s: session::Session,
985985
def_map: dm,
986986
region_maps: region_maps,
987987
node_types: @mut HashMap::new(),
988-
node_type_substs: @mut HashMap::new(),
988+
node_type_substs: RefCell::new(HashMap::new()),
989989
trait_refs: @mut HashMap::new(),
990990
trait_defs: @mut HashMap::new(),
991991
items: amap,
@@ -2676,14 +2676,16 @@ pub fn node_id_to_type(cx: ctxt, id: ast::NodeId) -> t {
26762676

26772677
// XXX(pcwalton): Makes a copy, bleh. Probably better to not do that.
26782678
pub fn node_id_to_type_params(cx: ctxt, id: ast::NodeId) -> ~[t] {
2679-
match cx.node_type_substs.find(&id) {
2679+
let node_type_substs = cx.node_type_substs.borrow();
2680+
match node_type_substs.get().find(&id) {
26802681
None => return ~[],
26812682
Some(ts) => return (*ts).clone(),
26822683
}
26832684
}
26842685

26852686
fn node_id_has_type_params(cx: ctxt, id: ast::NodeId) -> bool {
2686-
cx.node_type_substs.contains_key(&id)
2687+
let node_type_substs = cx.node_type_substs.borrow();
2688+
node_type_substs.get().contains_key(&id)
26872689
}
26882690

26892691
pub fn fn_is_variadic(fty: t) -> bool {

branches/try/src/librustc/middle/typeck/check/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub struct Inherited {
163163

164164
// Temporary tables:
165165
node_types: @mut HashMap<ast::NodeId, ty::t>,
166-
node_type_substs: @mut HashMap<ast::NodeId, ty::substs>,
166+
node_type_substs: RefCell<HashMap<ast::NodeId, ty::substs>>,
167167
adjustments: @mut HashMap<ast::NodeId, @ty::AutoAdjustment>,
168168
method_map: method_map,
169169
vtable_map: vtable_map,
@@ -263,7 +263,7 @@ impl Inherited {
263263
locals: @mut HashMap::new(),
264264
param_env: param_env,
265265
node_types: @mut HashMap::new(),
266-
node_type_substs: @mut HashMap::new(),
266+
node_type_substs: RefCell::new(HashMap::new()),
267267
adjustments: @mut HashMap::new(),
268268
method_map: @mut HashMap::new(),
269269
vtable_map: @mut HashMap::new(),
@@ -1106,7 +1106,9 @@ impl FnCtxt {
11061106
node_id,
11071107
ty::substs_to_str(self.tcx(), &substs),
11081108
self.tag());
1109-
self.inh.node_type_substs.insert(node_id, substs);
1109+
1110+
let mut node_type_substs = self.inh.node_type_substs.borrow_mut();
1111+
node_type_substs.get().insert(node_id, substs);
11101112
}
11111113
}
11121114

@@ -1181,7 +1183,8 @@ impl FnCtxt {
11811183
}
11821184

11831185
pub fn node_ty_substs(&self, id: ast::NodeId) -> ty::substs {
1184-
match self.inh.node_type_substs.find(&id) {
1186+
let mut node_type_substs = self.inh.node_type_substs.borrow_mut();
1187+
match node_type_substs.get().find(&id) {
11851188
Some(ts) => (*ts).clone(),
11861189
None => {
11871190
self.tcx().sess.bug(
@@ -1197,7 +1200,8 @@ impl FnCtxt {
11971200
id: ast::NodeId,
11981201
f: |&ty::substs| -> bool)
11991202
-> bool {
1200-
match self.inh.node_type_substs.find(&id) {
1203+
let node_type_substs = self.inh.node_type_substs.borrow();
1204+
match node_type_substs.get().find(&id) {
12011205
Some(s) => f(s),
12021206
None => true
12031207
}

branches/try/src/librustc/middle/typeck/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ pub fn write_substs_to_tcx(tcx: ty::ctxt,
248248
debug!("write_substs_to_tcx({}, {:?})", node_id,
249249
substs.map(|t| ppaux::ty_to_str(tcx, *t)));
250250
assert!(substs.iter().all(|t| !ty::type_needs_infer(*t)));
251-
tcx.node_type_substs.insert(node_id, substs);
251+
252+
let mut node_type_substs = tcx.node_type_substs.borrow_mut();
253+
node_type_substs.get().insert(node_id, substs);
252254
}
253255
}
254256
pub fn write_tpt_to_tcx(tcx: ty::ctxt,

0 commit comments

Comments
 (0)