Skip to content

Commit 7ffba5c

Browse files
committed
librustc: De-@mut llupvars in the translation crate context
1 parent de3d581 commit 7ffba5c

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ use util::sha2::Sha256;
6969
use middle::trans::type_::Type;
7070

7171
use std::c_str::ToCStr;
72+
use std::cell::RefCell;
7273
use std::hashmap::HashMap;
7374
use std::libc::c_uint;
7475
use std::vec;
@@ -1693,7 +1694,7 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext,
16931694
caller_expects_out_pointer: uses_outptr,
16941695
llargs: @mut HashMap::new(),
16951696
lllocals: @mut HashMap::new(),
1696-
llupvars: @mut HashMap::new(),
1697+
llupvars: RefCell::new(HashMap::new()),
16971698
id: id,
16981699
param_substs: param_substs,
16991700
span: sp,

src/librustc/middle/trans/closure.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,11 @@ pub fn load_environment(fcx: @mut FunctionContext,
328328
ast::ManagedSigil | ast::OwnedSigil => {}
329329
}
330330
let def_id = ast_util::def_id_of_def(cap_var.def);
331-
fcx.llupvars.insert(def_id.node, upvarptr);
331+
332+
{
333+
let mut llupvars = fcx.llupvars.borrow_mut();
334+
llupvars.get().insert(def_id.node, upvarptr);
335+
}
332336

333337
for &env_pointer_alloca in env_pointer_alloca.iter() {
334338
debuginfo::create_captured_var_metadata(

src/librustc/middle/trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ pub struct FunctionContext {
245245
// them in llallocas.
246246
lllocals: @mut HashMap<ast::NodeId, ValueRef>,
247247
// Same as above, but for closure upvars
248-
llupvars: @mut HashMap<ast::NodeId, ValueRef>,
248+
llupvars: RefCell<HashMap<ast::NodeId, ValueRef>>,
249249

250250
// The NodeId of the function, or -1 if it doesn't correspond to
251251
// a user-defined function.

src/librustc/middle/trans/expr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,8 @@ pub fn trans_local_var(bcx: @Block, def: ast::Def) -> Datum {
10841084
ast::DefUpvar(nid, _, _, _) => {
10851085
// Can't move upvars, so this is never a ZeroMemLastUse.
10861086
let local_ty = node_id_type(bcx, nid);
1087-
match bcx.fcx.llupvars.find(&nid) {
1087+
let llupvars = bcx.fcx.llupvars.borrow();
1088+
match llupvars.get().find(&nid) {
10881089
Some(&val) => {
10891090
Datum {
10901091
val: val,

0 commit comments

Comments
 (0)