librustc: De-@mut trait_impls in the type context
This commit is contained in:
parent
a66fcca9c9
commit
c554d23a9a
5 changed files with 25 additions and 13 deletions
|
|
@ -878,7 +878,8 @@ fn encode_inherent_implementations(ecx: &EncodeContext,
|
|||
fn encode_extension_implementations(ecx: &EncodeContext,
|
||||
ebml_w: &mut writer::Encoder,
|
||||
trait_def_id: DefId) {
|
||||
match ecx.tcx.trait_impls.find(&trait_def_id) {
|
||||
let trait_impls = ecx.tcx.trait_impls.borrow();
|
||||
match trait_impls.get().find(&trait_def_id) {
|
||||
None => {}
|
||||
Some(&implementations) => {
|
||||
for implementation in implementations.iter() {
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ struct ctxt_ {
|
|||
destructors: RefCell<HashSet<ast::DefId>>,
|
||||
|
||||
// Maps a trait onto a list of impls of that trait.
|
||||
trait_impls: @mut HashMap<ast::DefId, @mut ~[@Impl]>,
|
||||
trait_impls: RefCell<HashMap<ast::DefId, @mut ~[@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.
|
||||
|
|
@ -1005,7 +1005,7 @@ pub fn mk_ctxt(s: session::Session,
|
|||
supertraits: RefCell::new(HashMap::new()),
|
||||
destructor_for_type: RefCell::new(HashMap::new()),
|
||||
destructors: RefCell::new(HashSet::new()),
|
||||
trait_impls: @mut HashMap::new(),
|
||||
trait_impls: RefCell::new(HashMap::new()),
|
||||
inherent_impls: @mut HashMap::new(),
|
||||
impls: @mut HashMap::new(),
|
||||
used_unsafe: @mut HashSet::new(),
|
||||
|
|
@ -4498,10 +4498,11 @@ fn record_trait_implementation(tcx: ctxt,
|
|||
trait_def_id: DefId,
|
||||
implementation: @Impl) {
|
||||
let implementation_list;
|
||||
match tcx.trait_impls.find(&trait_def_id) {
|
||||
let mut trait_impls = tcx.trait_impls.borrow_mut();
|
||||
match trait_impls.get().find(&trait_def_id) {
|
||||
None => {
|
||||
implementation_list = @mut ~[];
|
||||
tcx.trait_impls.insert(trait_def_id, implementation_list);
|
||||
trait_impls.get().insert(trait_def_id, implementation_list);
|
||||
}
|
||||
Some(&existing_implementation_list) => {
|
||||
implementation_list = existing_implementation_list
|
||||
|
|
|
|||
|
|
@ -352,7 +352,8 @@ impl<'a> LookupContext<'a> {
|
|||
*trait_did);
|
||||
|
||||
// Look for explicit implementations.
|
||||
let opt_impl_infos = self.tcx().trait_impls.find(trait_did);
|
||||
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() {
|
||||
self.push_candidates_from_impl(
|
||||
|
|
|
|||
|
|
@ -329,7 +329,12 @@ fn search_for_vtable(vcx: &VtableContext,
|
|||
|
||||
// XXX: this is a bad way to do this, since we do
|
||||
// pointless allocations.
|
||||
let impls = tcx.trait_impls.find(&trait_ref.def_id).map_default(@mut ~[], |x| *x);
|
||||
let impls = {
|
||||
let trait_impls = tcx.trait_impls.borrow();
|
||||
trait_impls.get()
|
||||
.find(&trait_ref.def_id)
|
||||
.map_default(@mut ~[], |x| *x)
|
||||
};
|
||||
// impls is the list of all impls in scope for trait_ref.
|
||||
for im in impls.iter() {
|
||||
// im is one specific impl of trait_ref.
|
||||
|
|
|
|||
|
|
@ -402,10 +402,11 @@ impl CoherenceChecker {
|
|||
implementation: @Impl) {
|
||||
let tcx = self.crate_context.tcx;
|
||||
let implementation_list;
|
||||
match tcx.trait_impls.find(&base_def_id) {
|
||||
let mut trait_impls = tcx.trait_impls.borrow_mut();
|
||||
match trait_impls.get().find(&base_def_id) {
|
||||
None => {
|
||||
implementation_list = @mut ~[];
|
||||
tcx.trait_impls.insert(base_def_id, implementation_list);
|
||||
trait_impls.get().insert(base_def_id, implementation_list);
|
||||
}
|
||||
Some(&existing_implementation_list) => {
|
||||
implementation_list = existing_implementation_list;
|
||||
|
|
@ -416,7 +417,8 @@ impl CoherenceChecker {
|
|||
}
|
||||
|
||||
pub fn check_implementation_coherence(&self) {
|
||||
self.crate_context.tcx.trait_impls.each_key(|&trait_id| {
|
||||
let trait_impls = self.crate_context.tcx.trait_impls.borrow();
|
||||
trait_impls.get().each_key(|&trait_id| {
|
||||
self.check_implementation_coherence_of(trait_id);
|
||||
true
|
||||
});
|
||||
|
|
@ -455,7 +457,8 @@ impl CoherenceChecker {
|
|||
}
|
||||
|
||||
pub fn iter_impls_of_trait(&self, trait_def_id: DefId, f: |@Impl|) {
|
||||
match self.crate_context.tcx.trait_impls.find(&trait_def_id) {
|
||||
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() {
|
||||
f(im);
|
||||
|
|
@ -687,11 +690,12 @@ impl CoherenceChecker {
|
|||
let drop_trait = match tcx.lang_items.drop_trait() {
|
||||
Some(id) => id, None => { return }
|
||||
};
|
||||
let impls_opt = tcx.trait_impls.find(&drop_trait);
|
||||
|
||||
let trait_impls = tcx.trait_impls.borrow();
|
||||
let impls_opt = trait_impls.get().find(&drop_trait);
|
||||
let impls;
|
||||
match impls_opt {
|
||||
None => return, // No types with (new-style) destructors present.
|
||||
None => return, // No types with (new-style) dtors present.
|
||||
Some(found_impls) => impls = found_impls
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue