librustc: De-@mut inherent_impls in the type context
This commit is contained in:
parent
c554d23a9a
commit
42f7f7f437
5 changed files with 16 additions and 10 deletions
|
|
@ -442,7 +442,8 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
|
|||
ebml_w: &mut writer::Encoder,
|
||||
exp: &middle::resolve::Export2)
|
||||
-> bool {
|
||||
match ecx.tcx.inherent_impls.find(&exp.def_id) {
|
||||
let inherent_impls = ecx.tcx.inherent_impls.borrow();
|
||||
match inherent_impls.get().find(&exp.def_id) {
|
||||
Some(implementations) => {
|
||||
for &base_impl in implementations.iter() {
|
||||
for &m in base_impl.methods.iter() {
|
||||
|
|
@ -862,7 +863,8 @@ fn should_inline(attrs: &[Attribute]) -> bool {
|
|||
fn encode_inherent_implementations(ecx: &EncodeContext,
|
||||
ebml_w: &mut writer::Encoder,
|
||||
def_id: DefId) {
|
||||
match ecx.tcx.inherent_impls.find(&def_id) {
|
||||
let inherent_impls = ecx.tcx.inherent_impls.borrow();
|
||||
match inherent_impls.get().find(&def_id) {
|
||||
None => {}
|
||||
Some(&implementations) => {
|
||||
for implementation in implementations.iter() {
|
||||
|
|
|
|||
|
|
@ -282,7 +282,8 @@ impl DeadVisitor {
|
|||
// method of a private type is used, but the type itself is never
|
||||
// called directly.
|
||||
let def_id = local_def(id);
|
||||
match self.tcx.inherent_impls.find(&def_id) {
|
||||
let inherent_impls = self.tcx.inherent_impls.borrow();
|
||||
match inherent_impls.get().find(&def_id) {
|
||||
None => (),
|
||||
Some(ref impl_list) => {
|
||||
for impl_ in impl_list.iter() {
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ struct ctxt_ {
|
|||
// Maps a def_id of a type to a list of its inherent impls.
|
||||
// Contains implementations of methods that are inherent to a type.
|
||||
// Methods in these implementations don't need to be exported.
|
||||
inherent_impls: @mut HashMap<ast::DefId, @mut ~[@Impl]>,
|
||||
inherent_impls: RefCell<HashMap<ast::DefId, @mut ~[@Impl]>>,
|
||||
|
||||
// Maps a def_id of an impl to an Impl structure.
|
||||
// Note that this contains all of the impls that we know about,
|
||||
|
|
@ -1006,7 +1006,7 @@ pub fn mk_ctxt(s: session::Session,
|
|||
destructor_for_type: RefCell::new(HashMap::new()),
|
||||
destructors: RefCell::new(HashSet::new()),
|
||||
trait_impls: RefCell::new(HashMap::new()),
|
||||
inherent_impls: @mut HashMap::new(),
|
||||
inherent_impls: RefCell::new(HashMap::new()),
|
||||
impls: @mut HashMap::new(),
|
||||
used_unsafe: @mut HashSet::new(),
|
||||
used_mut_nodes: @mut HashSet::new(),
|
||||
|
|
@ -4549,10 +4549,11 @@ pub fn populate_implementations_for_type_if_necessary(tcx: ctxt,
|
|||
// If this is an inherent implementation, record it.
|
||||
if associated_traits.is_none() {
|
||||
let implementation_list;
|
||||
match tcx.inherent_impls.find(&type_id) {
|
||||
let mut inherent_impls = tcx.inherent_impls.borrow_mut();
|
||||
match inherent_impls.get().find(&type_id) {
|
||||
None => {
|
||||
implementation_list = @mut ~[];
|
||||
tcx.inherent_impls.insert(type_id, implementation_list);
|
||||
inherent_impls.get().insert(type_id, implementation_list);
|
||||
}
|
||||
Some(&existing_implementation_list) => {
|
||||
implementation_list = existing_implementation_list;
|
||||
|
|
|
|||
|
|
@ -527,7 +527,8 @@ impl<'a> LookupContext<'a> {
|
|||
// metadata if necessary.
|
||||
ty::populate_implementations_for_type_if_necessary(self.tcx(), did);
|
||||
|
||||
let opt_impl_infos = self.tcx().inherent_impls.find(&did);
|
||||
let inherent_impls = self.tcx().inherent_impls.borrow();
|
||||
let opt_impl_infos = inherent_impls.get().find(&did);
|
||||
for impl_infos in opt_impl_infos.iter() {
|
||||
for impl_info in impl_infos.iter() {
|
||||
self.push_candidates_from_impl(
|
||||
|
|
|
|||
|
|
@ -384,10 +384,11 @@ impl CoherenceChecker {
|
|||
implementation: @Impl) {
|
||||
let tcx = self.crate_context.tcx;
|
||||
let implementation_list;
|
||||
match tcx.inherent_impls.find(&base_def_id) {
|
||||
let mut inherent_impls = tcx.inherent_impls.borrow_mut();
|
||||
match inherent_impls.get().find(&base_def_id) {
|
||||
None => {
|
||||
implementation_list = @mut ~[];
|
||||
tcx.inherent_impls.insert(base_def_id, implementation_list);
|
||||
inherent_impls.get().insert(base_def_id, implementation_list);
|
||||
}
|
||||
Some(&existing_implementation_list) => {
|
||||
implementation_list = existing_implementation_list;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue