From 84e450347b00ca9a06b3f763fdebff8257e210e8 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 19 Dec 2013 18:32:03 -0800 Subject: [PATCH] librustc: De-`@mut` `provided_method_sources` in the type context --- src/librustc/middle/ty.rs | 15 ++++++++++----- src/librustc/middle/typeck/coherence.rs | 10 +++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 117b4559c2c0..4e95247ea53c 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -316,7 +316,7 @@ struct ctxt_ { normalized_cache: @mut HashMap, lang_items: middle::lang_items::LanguageItems, // A mapping of fake provided method def_ids to the default implementation - provided_method_sources: @mut HashMap, + provided_method_sources: RefCell>, supertraits: @mut HashMap, // Maps from def-id of a type or region parameter to its @@ -1005,7 +1005,7 @@ pub fn mk_ctxt(s: session::Session, adjustments: RefCell::new(HashMap::new()), normalized_cache: new_ty_hash(), lang_items: lang_items, - provided_method_sources: @mut HashMap::new(), + provided_method_sources: RefCell::new(HashMap::new()), supertraits: @mut HashMap::new(), destructor_for_type: @mut HashMap::new(), destructors: @mut HashSet::new(), @@ -3530,7 +3530,8 @@ pub fn def_has_ty_params(def: ast::Def) -> bool { } pub fn provided_source(cx: ctxt, id: ast::DefId) -> Option { - cx.provided_method_sources.find(&id).map(|x| *x) + let provided_method_sources = cx.provided_method_sources.borrow(); + provided_method_sources.get().find(&id).map(|x| *x) } pub fn provided_trait_methods(cx: ctxt, id: ast::DefId) -> ~[@Method] { @@ -4531,7 +4532,9 @@ pub fn populate_implementations_for_type_if_necessary(tcx: ctxt, // the map. This is a bit unfortunate. for method in implementation.methods.iter() { for source in method.provided_source.iter() { - tcx.provided_method_sources.insert(method.def_id, *source); + let mut provided_method_sources = + tcx.provided_method_sources.borrow_mut(); + provided_method_sources.get().insert(method.def_id, *source); } } @@ -4580,7 +4583,9 @@ pub fn populate_implementations_for_trait_if_necessary( // the map. This is a bit unfortunate. for method in implementation.methods.iter() { for source in method.provided_source.iter() { - tcx.provided_method_sources.insert(method.def_id, *source); + let mut provided_method_sources = + tcx.provided_method_sources.borrow_mut(); + provided_method_sources.get().insert(method.def_id, *source); } } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index f180a1c4d902..47f4cc5ea152 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -372,8 +372,10 @@ impl CoherenceChecker { // Pair the new synthesized ID up with the // ID of the method. - self.crate_context.tcx.provided_method_sources - .insert(new_did, trait_method.def_id); + let mut provided_method_sources = + self.crate_context.tcx.provided_method_sources.borrow_mut(); + provided_method_sources.get().insert(new_did, + trait_method.def_id); } } @@ -653,7 +655,9 @@ impl CoherenceChecker { // the map. This is a bit unfortunate. for method in implementation.methods.iter() { for source in method.provided_source.iter() { - tcx.provided_method_sources.insert(method.def_id, *source); + let mut provided_method_sources = tcx.provided_method_sources + .borrow_mut(); + provided_method_sources.get().insert(method.def_id, *source); } }