提交 f73dee17 编写于 作者: P Patrick Walton

librustc: De-`@mut` the export map

上级 c5f07cfc
......@@ -272,8 +272,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
method_map, ty_cx));
let maps = (external_exports, last_private_map);
let exported_items =
time(time_passes, "privacy checking", maps, |(a, b)|
let exported_items = time(time_passes, "privacy checking", maps, |(a, b)|
middle::privacy::check_crate(ty_cx, &method_map, &exp_map2,
a, b, crate));
......
......@@ -556,7 +556,8 @@ fn encode_reexports(ecx: &EncodeContext,
id: NodeId,
path: &[ast_map::path_elt]) {
debug!("(encoding info for module) encoding reexports for {}", id);
match ecx.reexports2.find(&id) {
let reexports2 = ecx.reexports2.borrow();
match reexports2.get().find(&id) {
Some(ref exports) => {
debug!("(encoding info for module) found reexports for {}", id);
for exp in exports.iter() {
......
......@@ -293,8 +293,9 @@ fn visit_mod(&mut self, m: &ast::_mod, _sp: Span, id: ast::NodeId, _: ()) {
// This code is here instead of in visit_item so that the
// crate module gets processed as well.
if self.prev_exported {
assert!(self.exp_map2.contains_key(&id), "wut {:?}", id);
for export in self.exp_map2.get(&id).iter() {
let exp_map2 = self.exp_map2.borrow();
assert!(exp_map2.get().contains_key(&id), "wut {:?}", id);
for export in exp_map2.get().get(&id).iter() {
if is_local(export.def_id) && export.reexport {
self.reexports.insert(export.def_id.node);
}
......
......@@ -29,7 +29,7 @@
use syntax::visit;
use syntax::visit::Visitor;
use std::cell::Cell;
use std::cell::{Cell, RefCell};
use std::uint;
use std::hashmap::{HashMap, HashSet};
use std::util;
......@@ -50,7 +50,7 @@ struct binding_info {
// This is the replacement export map. It maps a module to all of the exports
// within.
pub type ExportMap2 = @mut HashMap<NodeId, ~[Export2]>;
pub type ExportMap2 = @RefCell<HashMap<NodeId, ~[Export2]>>;
pub struct Export2 {
name: @str, // The name of the target.
......@@ -808,7 +808,7 @@ fn Resolver(session: Session,
namespaces: ~[ TypeNS, ValueNS ],
def_map: @mut HashMap::new(),
export_map2: @mut HashMap::new(),
export_map2: @RefCell::new(HashMap::new()),
trait_map: HashMap::new(),
used_imports: HashSet::new(),
external_exports: HashSet::new(),
......@@ -3249,7 +3249,8 @@ fn record_exports_for_module(&mut self, module_: @Module) {
self.add_exports_for_module(&mut exports2, module_);
match module_.def_id.get() {
Some(def_id) => {
self.export_map2.insert(def_id.node, exports2);
let mut export_map2 = self.export_map2.borrow_mut();
export_map2.get().insert(def_id.node, exports2);
debug!("(computing exports) writing exports for {} (some)",
def_id.node);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册