about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-12-22 16:31:20 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-12-26 15:54:37 -0800
commitfecef74d57307eb1ecbb4351ef644e04aafb6f9a (patch)
tree654c1a4422cb9d7f23647150f36ced7b9cea62e6 /src
parented819c9a81d138ab876c42ad35025ff432845a2c (diff)
downloadrust-fecef74d57307eb1ecbb4351ef644e04aafb6f9a.tar.gz
rust-fecef74d57307eb1ecbb4351ef644e04aafb6f9a.zip
librustc: De-`@mut` the inherent implementations list
Diffstat (limited to 'src')
-rw-r--r--src/librustc/metadata/encoder.rs6
-rw-r--r--src/librustc/middle/dead.rs3
-rw-r--r--src/librustc/middle/ty.rs10
-rw-r--r--src/librustc/middle/typeck/check/method.rs3
-rw-r--r--src/librustc/middle/typeck/coherence.rs6
5 files changed, 19 insertions, 9 deletions
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs
index eaf1054231f..b09b448e1fe 100644
--- a/src/librustc/metadata/encoder.rs
+++ b/src/librustc/metadata/encoder.rs
@@ -449,7 +449,8 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
     let inherent_impls = ecx.tcx.inherent_impls.borrow();
     match inherent_impls.get().find(&exp.def_id) {
         Some(implementations) => {
-            for &base_impl in implementations.iter() {
+            let implementations = implementations.borrow();
+            for &base_impl in implementations.get().iter() {
                 for &m in base_impl.methods.iter() {
                     if m.explicit_self == ast::sty_static {
                         encode_reexported_static_method(ecx, ebml_w, exp,
@@ -884,7 +885,8 @@ fn encode_inherent_implementations(ecx: &EncodeContext,
     match inherent_impls.get().find(&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_inherent_impl);
                 encode_def_id(ebml_w, implementation.did);
                 ebml_w.end_tag();
diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs
index aa58fc569a8..1fc95839c8d 100644
--- a/src/librustc/middle/dead.rs
+++ b/src/librustc/middle/dead.rs
@@ -287,7 +287,8 @@ impl DeadVisitor {
         match inherent_impls.get().find(&def_id) {
             None => (),
             Some(ref impl_list) => {
-                for impl_ in impl_list.iter() {
+                let impl_list = impl_list.borrow();
+                for impl_ in impl_list.get().iter() {
                     for method in impl_.methods.iter() {
                         if self.live_symbols.contains(&method.def_id.node) {
                             return true;
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index ef7cd14ae9b..ff925305acf 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -338,7 +338,7 @@ struct ctxt_ {
     // Maps a def_id of a type to a list of its inherent impls.
     // Contains implementations of methods that are inherent to a type.
     // Methods in these implementations don't need to be exported.
-    inherent_impls: RefCell<HashMap<ast::DefId, @mut ~[@Impl]>>,
+    inherent_impls: RefCell<HashMap<ast::DefId, @RefCell<~[@Impl]>>>,
 
     // Maps a def_id of an impl to an Impl structure.
     // Note that this contains all of the impls that we know about,
@@ -4561,14 +4561,18 @@ pub fn populate_implementations_for_type_if_necessary(tcx: ctxt,
             let mut inherent_impls = tcx.inherent_impls.borrow_mut();
             match inherent_impls.get().find(&type_id) {
                 None => {
-                    implementation_list = @mut ~[];
+                    implementation_list = @RefCell::new(~[]);
                     inherent_impls.get().insert(type_id, implementation_list);
                 }
                 Some(&existing_implementation_list) => {
                     implementation_list = existing_implementation_list;
                 }
             }
-            implementation_list.push(implementation);
+            {
+                let mut implementation_list =
+                    implementation_list.borrow_mut();
+                implementation_list.get().push(implementation);
+            }
         }
 
         // Store the implementation info.
diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs
index efee8c23535..0f92cdaae63 100644
--- a/src/librustc/middle/typeck/check/method.rs
+++ b/src/librustc/middle/typeck/check/method.rs
@@ -536,7 +536,8 @@ impl<'a> LookupContext<'a> {
         let inherent_impls = self.tcx().inherent_impls.borrow();
         let opt_impl_infos = inherent_impls.get().find(&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 inherent_candidates = self.inherent_candidates
                                                   .borrow_mut();
                 self.push_candidates_from_impl(inherent_candidates.get(),
diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs
index 481d815fe7b..b7e0e2078d9 100644
--- a/src/librustc/middle/typeck/coherence.rs
+++ b/src/librustc/middle/typeck/coherence.rs
@@ -45,6 +45,7 @@ use syntax::codemap::Span;
 use syntax::opt_vec;
 use syntax::visit;
 
+use std::cell::RefCell;
 use std::hashmap::HashSet;
 use std::result::Ok;
 use std::vec;
@@ -391,7 +392,7 @@ impl CoherenceChecker {
         let mut inherent_impls = tcx.inherent_impls.borrow_mut();
         match inherent_impls.get().find(&base_def_id) {
             None => {
-                implementation_list = @mut ~[];
+                implementation_list = @RefCell::new(~[]);
                 inherent_impls.get().insert(base_def_id, implementation_list);
             }
             Some(&existing_implementation_list) => {
@@ -399,7 +400,8 @@ impl CoherenceChecker {
             }
         }
 
-        implementation_list.push(implementation);
+        let mut implementation_list = implementation_list.borrow_mut();
+        implementation_list.get().push(implementation);
     }
 
     pub fn add_trait_impl(&self,