diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 64d4d5939d0..2b0d6479d0c 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -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); } diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 1804e8b1247..f567665256b 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -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; +pub type cnum_map = @RefCell>; pub enum MetadataBlob { MetadataVec(~[u8]), diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index b9a3bc47eb3..a0b339cc91d 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -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") } } diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index ae867fe6727..dd886b3054e 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -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 {