Skip to content

Commit 1fb425c

Browse files
committed
---
yaml --- r: 147611 b: refs/heads/try2 c: c5f07cf h: refs/heads/master i: 147609: ee0b444 147607: a22a1e5 v: v3
1 parent c8f296d commit 1fb425c

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 8ae01fc0ae8ee160a5713873177f9fc9957be8ab
8+
refs/heads/try2: c5f07cfc1adfb23523c986b1c7e1b099ebbd8605
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub struct SelfInfo {
158158
/// share the inherited fields.
159159
pub struct Inherited {
160160
infcx: @infer::InferCtxt,
161-
locals: @mut HashMap<ast::NodeId, ty::t>,
161+
locals: @RefCell<HashMap<ast::NodeId, ty::t>>,
162162
param_env: ty::ParameterEnvironment,
163163

164164
// Temporary tables:
@@ -260,7 +260,7 @@ impl Inherited {
260260
-> Inherited {
261261
Inherited {
262262
infcx: infer::new_infer_ctxt(tcx),
263-
locals: @mut HashMap::new(),
263+
locals: @RefCell::new(HashMap::new()),
264264
param_env: param_env,
265265
node_types: RefCell::new(HashMap::new()),
266266
node_type_substs: RefCell::new(HashMap::new()),
@@ -351,11 +351,13 @@ impl GatherLocalsVisitor {
351351
// infer the variable's type
352352
let var_id = self.fcx.infcx().next_ty_var_id();
353353
let var_ty = ty::mk_var(self.fcx.tcx(), var_id);
354-
self.fcx.inh.locals.insert(nid, var_ty);
354+
let mut locals = self.fcx.inh.locals.borrow_mut();
355+
locals.get().insert(nid, var_ty);
355356
}
356357
Some(typ) => {
357358
// take type that the user specified
358-
self.fcx.inh.locals.insert(nid, typ);
359+
let mut locals = self.fcx.inh.locals.borrow_mut();
360+
locals.get().insert(nid, typ);
359361
}
360362
}
361363
}
@@ -369,10 +371,13 @@ impl Visitor<()> for GatherLocalsVisitor {
369371
_ => Some(self.fcx.to_ty(local.ty))
370372
};
371373
self.assign(local.id, o_ty);
372-
debug!("Local variable {} is assigned type {}",
373-
self.fcx.pat_to_str(local.pat),
374-
self.fcx.infcx().ty_to_str(
375-
self.fcx.inh.locals.get_copy(&local.id)));
374+
{
375+
let locals = self.fcx.inh.locals.borrow();
376+
debug!("Local variable {} is assigned type {}",
377+
self.fcx.pat_to_str(local.pat),
378+
self.fcx.infcx().ty_to_str(
379+
locals.get().get_copy(&local.id)));
380+
}
376381
visit::walk_local(self, local, ());
377382

378383
}
@@ -382,10 +387,13 @@ impl Visitor<()> for GatherLocalsVisitor {
382387
ast::PatIdent(_, ref path, _)
383388
if pat_util::pat_is_binding(self.fcx.ccx.tcx.def_map, p) => {
384389
self.assign(p.id, None);
385-
debug!("Pattern binding {} is assigned to {}",
386-
self.tcx.sess.str_of(path.segments[0].identifier),
387-
self.fcx.infcx().ty_to_str(
388-
self.fcx.inh.locals.get_copy(&p.id)));
390+
{
391+
let locals = self.fcx.inh.locals.borrow();
392+
debug!("Pattern binding {} is assigned to {}",
393+
self.tcx.sess.str_of(path.segments[0].identifier),
394+
self.fcx.infcx().ty_to_str(
395+
locals.get().get_copy(&p.id)));
396+
}
389397
}
390398
_ => {}
391399
}
@@ -509,9 +517,10 @@ pub fn check_fn(ccx: @CrateCtxt,
509517
// Add the self parameter
510518
for self_info in opt_self_info.iter() {
511519
visit.assign(self_info.self_id, Some(self_info.self_ty));
520+
let locals = fcx.inh.locals.borrow();
512521
debug!("self is assigned to {}",
513522
fcx.infcx().ty_to_str(
514-
fcx.inh.locals.get_copy(&self_info.self_id)));
523+
locals.get().get_copy(&self_info.self_id)));
515524
}
516525

517526
// Add formal parameters.
@@ -1079,7 +1088,8 @@ impl FnCtxt {
10791088
}
10801089

10811090
pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> ty::t {
1082-
match self.inh.locals.find(&nid) {
1091+
let locals = self.inh.locals.borrow();
1092+
match locals.get().find(&nid) {
10831093
Some(&t) => t,
10841094
None => {
10851095
self.tcx().sess.span_bug(

0 commit comments

Comments
 (0)