Skip to content

Commit 84e4503

Browse files
committed
librustc: De-@mut provided_method_sources in the type context
1 parent 7cf6abc commit 84e4503

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/librustc/middle/ty.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ struct ctxt_ {
316316
normalized_cache: @mut HashMap<t, t>,
317317
lang_items: middle::lang_items::LanguageItems,
318318
// A mapping of fake provided method def_ids to the default implementation
319-
provided_method_sources: @mut HashMap<ast::DefId, ast::DefId>,
319+
provided_method_sources: RefCell<HashMap<ast::DefId, ast::DefId>>,
320320
supertraits: @mut HashMap<ast::DefId, @~[@TraitRef]>,
321321

322322
// Maps from def-id of a type or region parameter to its
@@ -1005,7 +1005,7 @@ pub fn mk_ctxt(s: session::Session,
10051005
adjustments: RefCell::new(HashMap::new()),
10061006
normalized_cache: new_ty_hash(),
10071007
lang_items: lang_items,
1008-
provided_method_sources: @mut HashMap::new(),
1008+
provided_method_sources: RefCell::new(HashMap::new()),
10091009
supertraits: @mut HashMap::new(),
10101010
destructor_for_type: @mut HashMap::new(),
10111011
destructors: @mut HashSet::new(),
@@ -3530,7 +3530,8 @@ pub fn def_has_ty_params(def: ast::Def) -> bool {
35303530
}
35313531

35323532
pub fn provided_source(cx: ctxt, id: ast::DefId) -> Option<ast::DefId> {
3533-
cx.provided_method_sources.find(&id).map(|x| *x)
3533+
let provided_method_sources = cx.provided_method_sources.borrow();
3534+
provided_method_sources.get().find(&id).map(|x| *x)
35343535
}
35353536

35363537
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,
45314532
// the map. This is a bit unfortunate.
45324533
for method in implementation.methods.iter() {
45334534
for source in method.provided_source.iter() {
4534-
tcx.provided_method_sources.insert(method.def_id, *source);
4535+
let mut provided_method_sources =
4536+
tcx.provided_method_sources.borrow_mut();
4537+
provided_method_sources.get().insert(method.def_id, *source);
45354538
}
45364539
}
45374540

@@ -4580,7 +4583,9 @@ pub fn populate_implementations_for_trait_if_necessary(
45804583
// the map. This is a bit unfortunate.
45814584
for method in implementation.methods.iter() {
45824585
for source in method.provided_source.iter() {
4583-
tcx.provided_method_sources.insert(method.def_id, *source);
4586+
let mut provided_method_sources =
4587+
tcx.provided_method_sources.borrow_mut();
4588+
provided_method_sources.get().insert(method.def_id, *source);
45844589
}
45854590
}
45864591

src/librustc/middle/typeck/coherence.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,10 @@ impl CoherenceChecker {
372372

373373
// Pair the new synthesized ID up with the
374374
// ID of the method.
375-
self.crate_context.tcx.provided_method_sources
376-
.insert(new_did, trait_method.def_id);
375+
let mut provided_method_sources =
376+
self.crate_context.tcx.provided_method_sources.borrow_mut();
377+
provided_method_sources.get().insert(new_did,
378+
trait_method.def_id);
377379
}
378380
}
379381

@@ -653,7 +655,9 @@ impl CoherenceChecker {
653655
// the map. This is a bit unfortunate.
654656
for method in implementation.methods.iter() {
655657
for source in method.provided_source.iter() {
656-
tcx.provided_method_sources.insert(method.def_id, *source);
658+
let mut provided_method_sources = tcx.provided_method_sources
659+
.borrow_mut();
660+
provided_method_sources.get().insert(method.def_id, *source);
657661
}
658662
}
659663

0 commit comments

Comments
 (0)