Skip to content

Commit 02f13ad

Browse files
committed
librustc: De-@mut the trait_methods_cache
1 parent 214d6bc commit 02f13ad

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
463463
ebml_w: &mut writer::Encoder,
464464
exp: &middle::resolve::Export2)
465465
-> bool {
466-
match ecx.tcx.trait_methods_cache.find(&exp.def_id) {
466+
let trait_methods_cache = ecx.tcx.trait_methods_cache.borrow();
467+
match trait_methods_cache.get().find(&exp.def_id) {
467468
Some(methods) => {
468469
for &m in methods.iter() {
469470
if m.explicit_self == ast::sty_static {

src/librustc/middle/ty.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ struct ctxt_ {
293293
trait_method_def_ids: RefCell<HashMap<DefId, @~[DefId]>>,
294294

295295
// A cache for the trait_methods() routine
296-
trait_methods_cache: @mut HashMap<DefId, @~[@Method]>,
296+
trait_methods_cache: RefCell<HashMap<DefId, @~[@Method]>>,
297297

298298
impl_trait_cache: @mut HashMap<ast::DefId, Option<@ty::TraitRef>>,
299299

@@ -1000,7 +1000,7 @@ pub fn mk_ctxt(s: session::Session,
10001000
enum_var_cache: @mut HashMap::new(),
10011001
methods: RefCell::new(HashMap::new()),
10021002
trait_method_def_ids: RefCell::new(HashMap::new()),
1003-
trait_methods_cache: @mut HashMap::new(),
1003+
trait_methods_cache: RefCell::new(HashMap::new()),
10041004
impl_trait_cache: @mut HashMap::new(),
10051005
ty_param_defs: @mut HashMap::new(),
10061006
adjustments: @mut HashMap::new(),
@@ -3591,12 +3591,13 @@ pub fn trait_method(cx: ctxt, trait_did: ast::DefId, idx: uint) -> @Method {
35913591

35923592

35933593
pub fn trait_methods(cx: ctxt, trait_did: ast::DefId) -> @~[@Method] {
3594-
match cx.trait_methods_cache.find(&trait_did) {
3594+
let mut trait_methods_cache = cx.trait_methods_cache.borrow_mut();
3595+
match trait_methods_cache.get().find(&trait_did) {
35953596
Some(&methods) => methods,
35963597
None => {
35973598
let def_ids = ty::trait_method_def_ids(cx, trait_did);
35983599
let methods = @def_ids.map(|d| ty::method(cx, *d));
3599-
cx.trait_methods_cache.insert(trait_did, methods);
3600+
trait_methods_cache.get().insert(trait_did, methods);
36003601
methods
36013602
}
36023603
}

0 commit comments

Comments
 (0)