diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index c331c71ac9ee..e0de68724769 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -463,7 +463,8 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext, ebml_w: &mut writer::Encoder, exp: &middle::resolve::Export2) -> bool { - match ecx.tcx.trait_methods_cache.find(&exp.def_id) { + let trait_methods_cache = ecx.tcx.trait_methods_cache.borrow(); + match trait_methods_cache.get().find(&exp.def_id) { Some(methods) => { for &m in methods.iter() { if m.explicit_self == ast::sty_static { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 399910a63c0c..eee00943d021 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -293,7 +293,7 @@ struct ctxt_ { trait_method_def_ids: RefCell>, // A cache for the trait_methods() routine - trait_methods_cache: @mut HashMap, + trait_methods_cache: RefCell>, impl_trait_cache: @mut HashMap>, @@ -1000,7 +1000,7 @@ pub fn mk_ctxt(s: session::Session, enum_var_cache: @mut HashMap::new(), methods: RefCell::new(HashMap::new()), trait_method_def_ids: RefCell::new(HashMap::new()), - trait_methods_cache: @mut HashMap::new(), + trait_methods_cache: RefCell::new(HashMap::new()), impl_trait_cache: @mut HashMap::new(), ty_param_defs: @mut HashMap::new(), adjustments: @mut HashMap::new(), @@ -3591,12 +3591,13 @@ pub fn trait_method(cx: ctxt, trait_did: ast::DefId, idx: uint) -> @Method { pub fn trait_methods(cx: ctxt, trait_did: ast::DefId) -> @~[@Method] { - match cx.trait_methods_cache.find(&trait_did) { + let mut trait_methods_cache = cx.trait_methods_cache.borrow_mut(); + match trait_methods_cache.get().find(&trait_did) { Some(&methods) => methods, None => { let def_ids = ty::trait_method_def_ids(cx, trait_did); let methods = @def_ids.map(|d| ty::method(cx, *d)); - cx.trait_methods_cache.insert(trait_did, methods); + trait_methods_cache.get().insert(trait_did, methods); methods } }