librustc: Fully de-@mut trait_impls in the type context

This commit is contained in:
Patrick Walton 2013-12-22 16:36:47 -08:00
parent fecef74d57
commit 47846110a4
5 changed files with 19 additions and 11 deletions

View file

@ -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();

View file

@ -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

View file

@ -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(

View file

@ -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.

View file

@ -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;