Skip to content

Commit 55a7b2f

Browse files
committed
librustc: De-@mut the impls table in the type context
1 parent 42f7f7f commit 55a7b2f

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
10841084
item_impl(_, ref opt_trait, ty, ref ast_methods) => {
10851085
// We need to encode information about the default methods we
10861086
// have inherited, so we drive this based on the impl structure.
1087-
let imp = tcx.impls.get(&def_id);
1087+
let impls = tcx.impls.borrow();
1088+
let imp = impls.get().get(&def_id);
10881089

10891090
add_to_index();
10901091
ebml_w.start_tag(tag_items_data_item);

src/librustc/middle/trans/meth.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ pub fn method_with_name(ccx: &CrateContext,
305305
}
306306
}
307307

308-
let imp = ccx.tcx.impls.find(&impl_id)
308+
let impls = ccx.tcx.impls.borrow();
309+
let imp = impls.get().find(&impl_id)
309310
.expect("could not find impl while translating");
310311
let meth = imp.methods.iter().find(|m| m.ident.name == name)
311312
.expect("could not find method while translating");

src/librustc/middle/ty.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ struct ctxt_ {
344344
// Note that this contains all of the impls that we know about,
345345
// including ones in other crates. It's not clear that this is the best
346346
// way to do it.
347-
impls: @mut HashMap<ast::DefId, @Impl>,
347+
impls: RefCell<HashMap<ast::DefId, @Impl>>,
348348

349349
// Set of used unsafe nodes (functions or blocks). Unsafe nodes not
350350
// present in this set can be warned about.
@@ -1007,7 +1007,7 @@ pub fn mk_ctxt(s: session::Session,
10071007
destructors: RefCell::new(HashSet::new()),
10081008
trait_impls: RefCell::new(HashMap::new()),
10091009
inherent_impls: RefCell::new(HashMap::new()),
1010-
impls: @mut HashMap::new(),
1010+
impls: RefCell::new(HashMap::new()),
10111011
used_unsafe: @mut HashSet::new(),
10121012
used_mut_nodes: @mut HashSet::new(),
10131013
impl_vtables: @mut HashMap::new(),
@@ -4563,7 +4563,8 @@ pub fn populate_implementations_for_type_if_necessary(tcx: ctxt,
45634563
}
45644564

45654565
// Store the implementation info.
4566-
tcx.impls.insert(implementation_def_id, implementation);
4566+
let mut impls = tcx.impls.borrow_mut();
4567+
impls.get().insert(implementation_def_id, implementation);
45674568
});
45684569

45694570
tcx.populated_external_types.insert(type_id);
@@ -4599,7 +4600,8 @@ pub fn populate_implementations_for_trait_if_necessary(
45994600
}
46004601

46014602
// Store the implementation info.
4602-
tcx.impls.insert(implementation_def_id, implementation);
4603+
let mut impls = tcx.impls.borrow_mut();
4604+
impls.get().insert(implementation_def_id, implementation);
46034605
});
46044606

46054607
tcx.populated_external_traits.insert(trait_id);

src/librustc/middle/typeck/coherence.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ impl CoherenceChecker {
313313
}
314314
}
315315

316-
tcx.impls.insert(implementation.did, implementation);
316+
let mut impls = tcx.impls.borrow_mut();
317+
impls.get().insert(implementation.did, implementation);
317318
}
318319

319320
// Creates default method IDs and performs type substitutions for an impl
@@ -665,7 +666,8 @@ impl CoherenceChecker {
665666
}
666667
}
667668

668-
tcx.impls.insert(implementation.did, implementation);
669+
let mut impls = tcx.impls.borrow_mut();
670+
impls.get().insert(implementation.did, implementation);
669671
}
670672

671673
// Adds implementations and traits from external crates to the coherence

0 commit comments

Comments
 (0)