Skip to content

Commit cb853ca

Browse files
committed
---
yaml --- r: 147566 b: refs/heads/try2 c: dd745b3 h: refs/heads/master v: v3
1 parent 1901dfe commit cb853ca

File tree

8 files changed

+28
-12
lines changed

8 files changed

+28
-12
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: 72f9cbe8ac36196bfb55b78e35fd92a0749d4740
8+
refs/heads/try2: dd745b388dad16973baf798a86b7141f96b76af4
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/astencode.rs

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

10191019
{
1020-
let r = maps.capture_map.find(&id);
1020+
let capture_map = maps.capture_map.borrow();
1021+
let r = capture_map.get().find(&id);
10211022
for &cap_vars in r.iter() {
10221023
ebml_w.tag(c::tag_table_capture_map, |ebml_w| {
10231024
ebml_w.id(id);
@@ -1283,7 +1284,10 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
12831284
at_vec::to_managed_move(
12841285
val_dsr.read_to_vec(
12851286
|val_dsr| val_dsr.read_capture_var(xcx)));
1286-
dcx.maps.capture_map.insert(id, cvars);
1287+
let mut capture_map = dcx.maps
1288+
.capture_map
1289+
.borrow_mut();
1290+
capture_map.get().insert(id, cvars);
12871291
}
12881292
_ => {
12891293
xcx.dcx.tcx.sess.bug(

branches/try2/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,8 @@ fn check_loans_in_fn<'a>(this: &mut CheckLoanCtxt<'a>,
713713
fn check_captured_variables(this: &CheckLoanCtxt,
714714
closure_id: ast::NodeId,
715715
span: Span) {
716-
let cap_vars = this.bccx.capture_map.get(&closure_id);
716+
let capture_map = this.bccx.capture_map.borrow();
717+
let cap_vars = capture_map.get().get(&closure_id);
717718
for cap_var in cap_vars.iter() {
718719
let var_id = ast_util::def_id_of_def(cap_var.def).node;
719720
let var_path = @LpVar(var_id);

branches/try2/src/librustc/middle/borrowck/gather_loans/gather_moves.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ fn gather_move_from_expr_or_pat(bccx: &BorrowckCtxt,
6969
pub fn gather_captures(bccx: &BorrowckCtxt,
7070
move_data: &mut MoveData,
7171
closure_expr: @ast::Expr) {
72-
let captured_vars = bccx.capture_map.get(&closure_expr.id);
72+
let capture_map = bccx.capture_map.borrow();
73+
let captured_vars = capture_map.get().get(&closure_expr.id);
7374
for captured_var in captured_vars.iter() {
7475
match captured_var.mode {
7576
moves::CapMove => {

branches/try2/src/librustc/middle/const_eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn lookup_variant_by_id(tcx: ty::ctxt,
124124
method_map: @mut HashMap::new(),
125125
vtable_map: @mut HashMap::new(),
126126
write_guard_map: @mut HashSet::new(),
127-
capture_map: @mut HashMap::new()
127+
capture_map: @RefCell::new(HashMap::new())
128128
};
129129
let e = match csearch::maybe_get_item_ast(tcx, enum_def,
130130
|a, b, c, d| astencode::decode_inlined_item(a,
@@ -174,7 +174,7 @@ pub fn lookup_const_by_id(tcx: ty::ctxt,
174174
method_map: @mut HashMap::new(),
175175
vtable_map: @mut HashMap::new(),
176176
write_guard_map: @mut HashSet::new(),
177-
capture_map: @mut HashMap::new()
177+
capture_map: @RefCell::new(HashMap::new())
178178
};
179179
let e = match csearch::maybe_get_item_ast(tcx, def_id,
180180
|a, b, c, d| astencode::decode_inlined_item(a, b, maps, c, d)) {

branches/try2/src/librustc/middle/liveness.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ fn visit_expr(v: &mut LivenessVisitor, expr: @Expr, this: @mut IrMaps) {
495495
// being the location that the variable is used. This results
496496
// in better error messages than just pointing at the closure
497497
// construction site.
498-
let cvs = this.capture_map.get(&expr.id);
498+
let capture_map = this.capture_map.borrow();
499+
let cvs = capture_map.get().get(&expr.id);
499500
let mut call_caps = ~[];
500501
for cv in cvs.iter() {
501502
match moves::moved_variable_node_id_from_def(cv.def) {

branches/try2/src/librustc/middle/moves.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ use util::common::indenter;
137137
use util::ppaux::UserString;
138138

139139
use std::at_vec;
140+
use std::cell::RefCell;
140141
use std::hashmap::{HashSet, HashMap};
141142
use syntax::ast::*;
142143
use syntax::ast_util;
@@ -158,7 +159,7 @@ pub struct CaptureVar {
158159
mode: CaptureMode // How variable is being accessed
159160
}
160161

161-
pub type CaptureMap = @mut HashMap<NodeId, @[CaptureVar]>;
162+
pub type CaptureMap = @RefCell<HashMap<NodeId, @[CaptureVar]>>;
162163

163164
pub type MovesMap = @mut HashSet<NodeId>;
164165

@@ -215,7 +216,7 @@ pub fn compute_moves(tcx: ty::ctxt,
215216
method_map: method_map,
216217
move_maps: MoveMaps {
217218
moves_map: @mut HashSet::new(),
218-
capture_map: @mut HashMap::new(),
219+
capture_map: @RefCell::new(HashMap::new()),
219220
moved_variables_set: @mut HashSet::new()
220221
}
221222
};
@@ -564,7 +565,12 @@ impl VisitContext {
564565
self.use_pat(a.pat);
565566
}
566567
let cap_vars = self.compute_captures(expr.id);
567-
self.move_maps.capture_map.insert(expr.id, cap_vars);
568+
{
569+
let mut capture_map = self.move_maps
570+
.capture_map
571+
.borrow_mut();
572+
capture_map.get().insert(expr.id, cap_vars);
573+
}
568574
self.consume_block(body);
569575
}
570576

branches/try2/src/librustc/middle/trans/closure.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,10 @@ pub fn trans_expr_fn(bcx: @Block,
400400

401401
let Result {bcx: bcx, val: closure} = match sigil {
402402
ast::BorrowedSigil | ast::ManagedSigil | ast::OwnedSigil => {
403-
let cap_vars = ccx.maps.capture_map.get_copy(&user_id);
403+
let cap_vars = {
404+
let capture_map = ccx.maps.capture_map.borrow();
405+
capture_map.get().get_copy(&user_id)
406+
};
404407
let ClosureResult {llbox, cdata_ty, bcx}
405408
= build_closure(bcx, cap_vars, sigil);
406409
trans_closure(ccx,

0 commit comments

Comments
 (0)