Skip to content

Commit 7522838

Browse files
committed
librustc: De-@mut destructor_for_type in the type context
1 parent 4dc923f commit 7522838

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/librustc/middle/reachable.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ impl ReachableContext {
374374
// this properly would result in the necessity of computing *type*
375375
// reachability, which might result in a compile time loss.
376376
fn mark_destructors_reachable(&self) {
377-
for (_, destructor_def_id) in self.tcx.destructor_for_type.iter() {
377+
let destructor_for_type = self.tcx.destructor_for_type.borrow();
378+
for (_, destructor_def_id) in destructor_for_type.get().iter() {
378379
if destructor_def_id.crate == ast::LOCAL_CRATE {
379380
self.reachable_symbols.insert(destructor_def_id.node);
380381
}

src/librustc/middle/ty.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ struct ctxt_ {
327327
// of the method that implements its destructor. If the type is not
328328
// present in this map, it does not have a destructor. This map is
329329
// populated during the coherence phase of typechecking.
330-
destructor_for_type: @mut HashMap<ast::DefId, ast::DefId>,
330+
destructor_for_type: RefCell<HashMap<ast::DefId, ast::DefId>>,
331331

332332
// A method will be in this list if and only if it is a destructor.
333333
destructors: @mut HashSet<ast::DefId>,
@@ -1003,7 +1003,7 @@ pub fn mk_ctxt(s: session::Session,
10031003
lang_items: lang_items,
10041004
provided_method_sources: RefCell::new(HashMap::new()),
10051005
supertraits: RefCell::new(HashMap::new()),
1006-
destructor_for_type: @mut HashMap::new(),
1006+
destructor_for_type: RefCell::new(HashMap::new()),
10071007
destructors: @mut HashSet::new(),
10081008
trait_impls: @mut HashMap::new(),
10091009
inherent_impls: @mut HashMap::new(),
@@ -3813,7 +3813,8 @@ impl DtorKind {
38133813
/* If struct_id names a struct with a dtor, return Some(the dtor's id).
38143814
Otherwise return none. */
38153815
pub fn ty_dtor(cx: ctxt, struct_id: DefId) -> DtorKind {
3816-
match cx.destructor_for_type.find(&struct_id) {
3816+
let destructor_for_type = cx.destructor_for_type.borrow();
3817+
match destructor_for_type.get().find(&struct_id) {
38173818
Some(&method_def_id) => {
38183819
let flag = !has_attr(cx, struct_id, "unsafe_no_drop_flag");
38193820

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,10 @@ impl<'a> LookupContext<'a> {
11571157
// that self has been merged in? -sully
11581158
method_param(method_param { trait_id: trait_id, .. }) |
11591159
method_object(method_object { trait_id: trait_id, .. }) => {
1160-
bad = self.tcx().destructor_for_type.contains_key(&trait_id);
1160+
let destructor_for_type = self.tcx()
1161+
.destructor_for_type
1162+
.borrow();
1163+
bad = destructor_for_type.get().contains_key(&trait_id);
11611164
}
11621165
}
11631166

src/librustc/middle/typeck/coherence.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,10 @@ impl CoherenceChecker {
705705
let self_type = self.get_self_type_for_implementation(*impl_info);
706706
match ty::get(self_type.ty).sty {
707707
ty::ty_struct(type_def_id, _) => {
708-
tcx.destructor_for_type.insert(type_def_id,
709-
method_def_id);
708+
let mut destructor_for_type = tcx.destructor_for_type
709+
.borrow_mut();
710+
destructor_for_type.get().insert(type_def_id,
711+
method_def_id);
710712
tcx.destructors.insert(method_def_id);
711713
}
712714
_ => {

0 commit comments

Comments
 (0)