提交 fecef74d 编写于 作者: P Patrick Walton

librustc: De-`@mut` the inherent implementations list

上级 ed819c9a
......@@ -449,7 +449,8 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
let inherent_impls = ecx.tcx.inherent_impls.borrow();
match inherent_impls.get().find(&exp.def_id) {
Some(implementations) => {
for &base_impl in implementations.iter() {
let implementations = implementations.borrow();
for &base_impl in implementations.get().iter() {
for &m in base_impl.methods.iter() {
if m.explicit_self == ast::sty_static {
encode_reexported_static_method(ecx, ebml_w, exp,
......@@ -884,7 +885,8 @@ fn encode_inherent_implementations(ecx: &EncodeContext,
match inherent_impls.get().find(&def_id) {
None => {}
Some(&implementations) => {
for implementation in implementations.iter() {
let implementations = implementations.borrow();
for implementation in implementations.get().iter() {
ebml_w.start_tag(tag_items_data_item_inherent_impl);
encode_def_id(ebml_w, implementation.did);
ebml_w.end_tag();
......
......@@ -287,7 +287,8 @@ fn symbol_is_live(&mut self, id: ast::NodeId,
match inherent_impls.get().find(&def_id) {
None => (),
Some(ref impl_list) => {
for impl_ in impl_list.iter() {
let impl_list = impl_list.borrow();
for impl_ in impl_list.get().iter() {
for method in impl_.methods.iter() {
if self.live_symbols.contains(&method.def_id.node) {
return true;
......
......@@ -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: RefCell<HashMap<ast::DefId, @mut ~[@Impl]>>,
inherent_impls: RefCell<HashMap<ast::DefId, @RefCell<~[@Impl]>>>,
// Maps a def_id of an impl to an Impl structure.
// Note that this contains all of the impls that we know about,
......@@ -4561,14 +4561,18 @@ pub fn populate_implementations_for_type_if_necessary(tcx: ctxt,
let mut inherent_impls = tcx.inherent_impls.borrow_mut();
match inherent_impls.get().find(&type_id) {
None => {
implementation_list = @mut ~[];
implementation_list = @RefCell::new(~[]);
inherent_impls.get().insert(type_id, implementation_list);
}
Some(&existing_implementation_list) => {
implementation_list = existing_implementation_list;
}
}
implementation_list.push(implementation);
{
let mut implementation_list =
implementation_list.borrow_mut();
implementation_list.get().push(implementation);
}
}
// Store the implementation info.
......
......@@ -536,7 +536,8 @@ fn push_inherent_impl_candidates_for_type(&self, did: DefId) {
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() {
let impl_infos = impl_infos.borrow();
for impl_info in impl_infos.get().iter() {
let mut inherent_candidates = self.inherent_candidates
.borrow_mut();
self.push_candidates_from_impl(inherent_candidates.get(),
......
......@@ -45,6 +45,7 @@
use syntax::opt_vec;
use syntax::visit;
use std::cell::RefCell;
use std::hashmap::HashSet;
use std::result::Ok;
use std::vec;
......@@ -391,7 +392,7 @@ pub fn add_inherent_impl(&self,
let mut inherent_impls = tcx.inherent_impls.borrow_mut();
match inherent_impls.get().find(&base_def_id) {
None => {
implementation_list = @mut ~[];
implementation_list = @RefCell::new(~[]);
inherent_impls.get().insert(base_def_id, implementation_list);
}
Some(&existing_implementation_list) => {
......@@ -399,7 +400,8 @@ pub fn add_inherent_impl(&self,
}
}
implementation_list.push(implementation);
let mut implementation_list = implementation_list.borrow_mut();
implementation_list.get().push(implementation);
}
pub fn add_trait_impl(&self,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册