提交 72f9cbe8 编写于 作者: P Patrick Walton

librustc: De-`@mut` the borrow check's root map

上级 c4661fd2
......@@ -279,7 +279,9 @@ fn check_root(&self,
// Add a record of what is required
let rm_key = root_map_key {id: cmt_deref.id, derefs: derefs};
let root_info = RootInfo {scope: root_scope, freeze: opt_dyna};
self.bccx.root_map.insert(rm_key, root_info);
let mut root_map = self.bccx.root_map.borrow_mut();
root_map.get().insert(rm_key, root_info);
debug!("root_key: {:?} root_info: {:?}", rm_key, root_info);
Ok(())
......
......@@ -20,6 +20,7 @@
use util::common::stmt_set;
use util::ppaux::{note_and_explain_region, Repr, UserString};
use std::cell::RefCell;
use std::hashmap::{HashSet, HashMap};
use std::ops::{BitOr, BitAnd};
use std::result::{Result};
......@@ -413,10 +414,10 @@ pub struct RootInfo {
freeze: Option<DynaFreezeKind> // Some() if we should freeze box at runtime
}
pub type root_map = @mut HashMap<root_map_key, RootInfo>;
pub type root_map = @RefCell<HashMap<root_map_key, RootInfo>>;
pub fn root_map() -> root_map {
return @mut HashMap::new();
return @RefCell::new(HashMap::new());
}
pub enum DynaFreezeKind {
......
......@@ -19,6 +19,7 @@
use syntax::visit::Visitor;
use syntax::ast::*;
use std::cell::RefCell;
use std::hashmap::{HashMap, HashSet};
//
......@@ -119,7 +120,7 @@ fn variant_expr(variants: &[ast::P<ast::variant>], id: ast::NodeId) -> Option<@E
}
}
let maps = astencode::Maps {
root_map: @mut HashMap::new(),
root_map: @RefCell::new(HashMap::new()),
method_map: @mut HashMap::new(),
vtable_map: @mut HashMap::new(),
write_guard_map: @mut HashSet::new(),
......@@ -169,7 +170,7 @@ pub fn lookup_const_by_id(tcx: ty::ctxt,
}
}
let maps = astencode::Maps {
root_map: @mut HashMap::new(),
root_map: @RefCell::new(HashMap::new()),
method_map: @mut HashMap::new(),
vtable_map: @mut HashMap::new(),
write_guard_map: @mut HashSet::new(),
......
......@@ -1112,7 +1112,8 @@ fn pats_require_rooting(bcx: @Block,
m.iter().any(|br| {
let pat_id = br.pats[col].id;
let key = root_map_key {id: pat_id, derefs: 0u };
bcx.ccx().maps.root_map.contains_key(&key)
let root_map = bcx.ccx().maps.root_map.borrow();
root_map.get().contains_key(&key)
})
}
......
......@@ -45,9 +45,12 @@ pub fn root_and_write_guard(datum: &Datum,
//
// (Note: root'd values are always boxes)
let ccx = bcx.ccx();
bcx = match ccx.maps.root_map.find(&key) {
None => bcx,
Some(&root_info) => root(datum, bcx, span, key, root_info)
bcx = {
let root_map = ccx.maps.root_map.borrow();
match root_map.get().find(&key) {
None => bcx,
Some(&root_info) => root(datum, bcx, span, key, root_info)
}
};
// Perform the write guard, if necessary.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册