diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 11a63db6aba..92586863a85 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -521,14 +521,18 @@ pub fn symbol_hash(tcx: ty::ctxt, } pub fn get_symbol_hash(ccx: &mut CrateContext, t: ty::t) -> @str { - match ccx.type_hashcodes.find(&t) { - Some(&h) => h, - None => { - let hash = symbol_hash(ccx.tcx, &mut ccx.symbol_hasher, t, &ccx.link_meta); - ccx.type_hashcodes.insert(t, hash); - hash - } + { + let type_hashcodes = ccx.type_hashcodes.borrow(); + match type_hashcodes.get().find(&t) { + Some(&h) => return h, + None => {} + } } + + let mut type_hashcodes = ccx.type_hashcodes.borrow_mut(); + let hash = symbol_hash(ccx.tcx, &mut ccx.symbol_hasher, t, &ccx.link_meta); + type_hashcodes.get().insert(t, hash); + hash } diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index 23e6e897f59..8939894ee38 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -96,7 +96,7 @@ pub struct CrateContext { llsizingtypes: RefCell>, adt_reprs: RefCell>, symbol_hasher: Sha256, - type_hashcodes: HashMap, + type_hashcodes: RefCell>, type_short_names: HashMap, all_llvm_symbols: HashSet<@str>, tcx: ty::ctxt, @@ -207,7 +207,7 @@ pub fn new(sess: session::Session, llsizingtypes: RefCell::new(HashMap::new()), adt_reprs: RefCell::new(HashMap::new()), symbol_hasher: symbol_hasher, - type_hashcodes: HashMap::new(), + type_hashcodes: RefCell::new(HashMap::new()), type_short_names: HashMap::new(), all_llvm_symbols: HashSet::new(), tcx: tcx,