about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-12-22 16:36:47 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-12-26 15:54:37 -0800
commit47846110a469d7682189e75b3bfe35f9ff02a9aa (patch)
tree12494a36889e893f188d1f1c4eca1d031115d482 /src
parentfecef74d57307eb1ecbb4351ef644e04aafb6f9a (diff)
downloadrust-47846110a469d7682189e75b3bfe35f9ff02a9aa.tar.gz
rust-47846110a469d7682189e75b3bfe35f9ff02a9aa.zip
librustc: Fully de-`@mut` `trait_impls` in the type context
Diffstat (limited to 'src')
-rw-r--r--src/librustc/metadata/encoder.rs3
-rw-r--r--src/librustc/middle/ty.rs7
-rw-r--r--src/librustc/middle/typeck/check/method.rs3
-rw-r--r--src/librustc/middle/typeck/check/vtable.rs6
-rw-r--r--src/librustc/middle/typeck/coherence.rs11
5 files changed, 19 insertions, 11 deletions
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs
index b09b448e1fe..961431ca11d 100644
--- a/src/librustc/metadata/encoder.rs
+++ b/src/librustc/metadata/encoder.rs
@@ -903,7 +903,8 @@ fn encode_extension_implementations(ecx: &EncodeContext,
     match trait_impls.get().find(&trait_def_id) {
         None => {}
         Some(&implementations) => {
-            for implementation in implementations.iter() {
+            let implementations = implementations.borrow();
+            for implementation in implementations.get().iter() {
                 ebml_w.start_tag(tag_items_data_item_extension_impl);
                 encode_def_id(ebml_w, implementation.did);
                 ebml_w.end_tag();
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index ff925305acf..12e7439744b 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -333,7 +333,7 @@ struct ctxt_ {
     destructors: RefCell<HashSet<ast::DefId>>,
 
     // Maps a trait onto a list of impls of that trait.
-    trait_impls: RefCell<HashMap<ast::DefId, @mut ~[@Impl]>>,
+    trait_impls: RefCell<HashMap<ast::DefId, @RefCell<~[@Impl]>>>,
 
     // Maps a def_id of a type to a list of its inherent impls.
     // Contains implementations of methods that are inherent to a type.
@@ -4507,7 +4507,7 @@ fn record_trait_implementation(tcx: ctxt,
     let mut trait_impls = tcx.trait_impls.borrow_mut();
     match trait_impls.get().find(&trait_def_id) {
         None => {
-            implementation_list = @mut ~[];
+            implementation_list = @RefCell::new(~[]);
             trait_impls.get().insert(trait_def_id, implementation_list);
         }
         Some(&existing_implementation_list) => {
@@ -4515,7 +4515,8 @@ fn record_trait_implementation(tcx: ctxt,
         }
     }
 
-    implementation_list.push(implementation);
+    let mut implementation_list = implementation_list.borrow_mut();
+    implementation_list.get().push(implementation);
 }
 
 /// Populates the type context with all the implementations for the given type
diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs
index 0f92cdaae63..7fc2798c7aa 100644
--- a/src/librustc/middle/typeck/check/method.rs
+++ b/src/librustc/middle/typeck/check/method.rs
@@ -357,7 +357,8 @@ impl<'a> LookupContext<'a> {
                 let trait_impls = self.tcx().trait_impls.borrow();
                 let opt_impl_infos = trait_impls.get().find(trait_did);
                 for impl_infos in opt_impl_infos.iter() {
-                    for impl_info in impl_infos.iter() {
+                    let impl_infos = impl_infos.borrow();
+                    for impl_info in impl_infos.get().iter() {
                         let mut extension_candidates =
                             self.extension_candidates.borrow_mut();
                         self.push_candidates_from_impl(
diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs
index a773a3a1975..212c37f4ed1 100644
--- a/src/librustc/middle/typeck/check/vtable.rs
+++ b/src/librustc/middle/typeck/check/vtable.rs
@@ -24,6 +24,7 @@ use middle::subst::Subst;
 use util::common::indenter;
 use util::ppaux;
 
+use std::cell::RefCell;
 use std::hashmap::HashSet;
 use std::result;
 use syntax::ast;
@@ -333,10 +334,11 @@ fn search_for_vtable(vcx: &VtableContext,
         let trait_impls = tcx.trait_impls.borrow();
         trait_impls.get()
                    .find(&trait_ref.def_id)
-                   .map_default(@mut ~[], |x| *x)
+                   .map_default(@RefCell::new(~[]), |x| *x)
     };
     // impls is the list of all impls in scope for trait_ref.
-    for im in impls.iter() {
+    let impls = impls.borrow();
+    for im in impls.get().iter() {
         // im is one specific impl of trait_ref.
 
         // First, ensure we haven't processed this impl yet.
diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs
index b7e0e2078d9..d3cd6465edf 100644
--- a/src/librustc/middle/typeck/coherence.rs
+++ b/src/librustc/middle/typeck/coherence.rs
@@ -412,7 +412,7 @@ impl CoherenceChecker {
         let mut trait_impls = tcx.trait_impls.borrow_mut();
         match trait_impls.get().find(&base_def_id) {
             None => {
-                implementation_list = @mut ~[];
+                implementation_list = @RefCell::new(~[]);
                 trait_impls.get().insert(base_def_id, implementation_list);
             }
             Some(&existing_implementation_list) => {
@@ -420,7 +420,8 @@ impl CoherenceChecker {
             }
         }
 
-        implementation_list.push(implementation);
+        let mut implementation_list = implementation_list.borrow_mut();
+        implementation_list.get().push(implementation);
     }
 
     pub fn check_implementation_coherence(&self) {
@@ -467,7 +468,8 @@ impl CoherenceChecker {
         let trait_impls = self.crate_context.tcx.trait_impls.borrow();
         match trait_impls.get().find(&trait_def_id) {
             Some(impls) => {
-                for &im in impls.iter() {
+                let impls = impls.borrow();
+                for &im in impls.get().iter() {
                     f(im);
                 }
             }
@@ -708,7 +710,8 @@ impl CoherenceChecker {
             Some(found_impls) => impls = found_impls
         }
 
-        for impl_info in impls.iter() {
+        let impls = impls.borrow();
+        for impl_info in impls.get().iter() {
             if impl_info.methods.len() < 1 {
                 // We'll error out later. For now, just don't ICE.
                 continue;