Skip to content

Commit fecef74

Browse files
committed
librustc: De-@mut the inherent implementations list
1 parent ed819c9 commit fecef74

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

src/librustc/metadata/encoder.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
449449
let inherent_impls = ecx.tcx.inherent_impls.borrow();
450450
match inherent_impls.get().find(&exp.def_id) {
451451
Some(implementations) => {
452-
for &base_impl in implementations.iter() {
452+
let implementations = implementations.borrow();
453+
for &base_impl in implementations.get().iter() {
453454
for &m in base_impl.methods.iter() {
454455
if m.explicit_self == ast::sty_static {
455456
encode_reexported_static_method(ecx, ebml_w, exp,
@@ -884,7 +885,8 @@ fn encode_inherent_implementations(ecx: &EncodeContext,
884885
match inherent_impls.get().find(&def_id) {
885886
None => {}
886887
Some(&implementations) => {
887-
for implementation in implementations.iter() {
888+
let implementations = implementations.borrow();
889+
for implementation in implementations.get().iter() {
888890
ebml_w.start_tag(tag_items_data_item_inherent_impl);
889891
encode_def_id(ebml_w, implementation.did);
890892
ebml_w.end_tag();

src/librustc/middle/dead.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ impl DeadVisitor {
287287
match inherent_impls.get().find(&def_id) {
288288
None => (),
289289
Some(ref impl_list) => {
290-
for impl_ in impl_list.iter() {
290+
let impl_list = impl_list.borrow();
291+
for impl_ in impl_list.get().iter() {
291292
for method in impl_.methods.iter() {
292293
if self.live_symbols.contains(&method.def_id.node) {
293294
return true;

src/librustc/middle/ty.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ struct ctxt_ {
338338
// Maps a def_id of a type to a list of its inherent impls.
339339
// Contains implementations of methods that are inherent to a type.
340340
// Methods in these implementations don't need to be exported.
341-
inherent_impls: RefCell<HashMap<ast::DefId, @mut ~[@Impl]>>,
341+
inherent_impls: RefCell<HashMap<ast::DefId, @RefCell<~[@Impl]>>>,
342342

343343
// Maps a def_id of an impl to an Impl structure.
344344
// 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,
45614561
let mut inherent_impls = tcx.inherent_impls.borrow_mut();
45624562
match inherent_impls.get().find(&type_id) {
45634563
None => {
4564-
implementation_list = @mut ~[];
4564+
implementation_list = @RefCell::new(~[]);
45654565
inherent_impls.get().insert(type_id, implementation_list);
45664566
}
45674567
Some(&existing_implementation_list) => {
45684568
implementation_list = existing_implementation_list;
45694569
}
45704570
}
4571-
implementation_list.push(implementation);
4571+
{
4572+
let mut implementation_list =
4573+
implementation_list.borrow_mut();
4574+
implementation_list.get().push(implementation);
4575+
}
45724576
}
45734577

45744578
// Store the implementation info.

src/librustc/middle/typeck/check/method.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,8 @@ impl<'a> LookupContext<'a> {
536536
let inherent_impls = self.tcx().inherent_impls.borrow();
537537
let opt_impl_infos = inherent_impls.get().find(&did);
538538
for impl_infos in opt_impl_infos.iter() {
539-
for impl_info in impl_infos.iter() {
539+
let impl_infos = impl_infos.borrow();
540+
for impl_info in impl_infos.get().iter() {
540541
let mut inherent_candidates = self.inherent_candidates
541542
.borrow_mut();
542543
self.push_candidates_from_impl(inherent_candidates.get(),

src/librustc/middle/typeck/coherence.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use syntax::codemap::Span;
4545
use syntax::opt_vec;
4646
use syntax::visit;
4747

48+
use std::cell::RefCell;
4849
use std::hashmap::HashSet;
4950
use std::result::Ok;
5051
use std::vec;
@@ -391,15 +392,16 @@ impl CoherenceChecker {
391392
let mut inherent_impls = tcx.inherent_impls.borrow_mut();
392393
match inherent_impls.get().find(&base_def_id) {
393394
None => {
394-
implementation_list = @mut ~[];
395+
implementation_list = @RefCell::new(~[]);
395396
inherent_impls.get().insert(base_def_id, implementation_list);
396397
}
397398
Some(&existing_implementation_list) => {
398399
implementation_list = existing_implementation_list;
399400
}
400401
}
401402

402-
implementation_list.push(implementation);
403+
let mut implementation_list = implementation_list.borrow_mut();
404+
implementation_list.get().push(implementation);
403405
}
404406

405407
pub fn add_trait_impl(&self,

0 commit comments

Comments
 (0)