librustc: De-@mut the cnum_map

This commit is contained in:
Patrick Walton 2013-12-21 18:17:29 -08:00
parent 5a9c37b7f5
commit 620be9235d
4 changed files with 14 additions and 7 deletions

View File

@ -15,6 +15,7 @@ use metadata::cstore;
use metadata::decoder;
use metadata::loader;
use std::cell::RefCell;
use std::hashmap::HashMap;
use syntax::ast;
use syntax::abi;
@ -347,5 +348,5 @@ fn resolve_crate_deps(e: &mut Env, cdata: &[u8]) -> cstore::cnum_map {
}
}
}
return @mut cnum_map;
return @RefCell::new(cnum_map);
}

View File

@ -24,7 +24,7 @@ use syntax::parse::token::ident_interner;
// local crate numbers (as generated during this session). Each external
// crate may refer to types in other external crates, and each has their
// own crate numbers.
pub type cnum_map = @mut HashMap<ast::CrateNum, ast::CrateNum>;
pub type cnum_map = @RefCell<HashMap<ast::CrateNum, ast::CrateNum>>;
pub enum MetadataBlob {
MetadataVec(~[u8]),

View File

@ -1197,9 +1197,15 @@ pub fn translate_def_id(cdata: Cmd, did: ast::DefId) -> ast::DefId {
return ast::DefId { crate: cdata.cnum, node: did.node };
}
match cdata.cnum_map.find(&did.crate) {
option::Some(&n) => ast::DefId { crate: n, node: did.node },
option::None => fail!("didn't find a crate in the cnum_map")
let cnum_map = cdata.cnum_map.borrow();
match cnum_map.get().find(&did.crate) {
Some(&n) => {
ast::DefId {
crate: n,
node: did.node,
}
}
None => fail!("didn't find a crate in the cnum_map")
}
}

View File

@ -83,7 +83,7 @@ pub fn check_crate(
capture_map: capture_map,
root_map: root_map(),
write_guard_map: @RefCell::new(HashSet::new()),
stats: @mut BorrowStats {
stats: @BorrowStats {
loaned_paths_same: Cell::new(0),
loaned_paths_imm: Cell::new(0),
stable_paths: Cell::new(0),
@ -172,7 +172,7 @@ pub struct BorrowckCtxt {
write_guard_map: write_guard_map,
// Statistics:
stats: @mut BorrowStats
stats: @BorrowStats
}
pub struct BorrowStats {