@@ -142,8 +142,8 @@ pub fn lookup(
142
142
m_name : m_name,
143
143
supplied_tps : supplied_tps,
144
144
impl_dups : impl_dups,
145
- inherent_candidates : @mut ~[ ] ,
146
- extension_candidates : @mut ~[ ] ,
145
+ inherent_candidates : @RefCell :: new ( ~[ ] ) ,
146
+ extension_candidates : @RefCell :: new ( ~[ ] ) ,
147
147
deref_args : deref_args,
148
148
check_traits : check_traits,
149
149
autoderef_receiver : autoderef_receiver,
@@ -176,8 +176,8 @@ pub struct LookupContext<'a> {
176
176
m_name : ast:: Name ,
177
177
supplied_tps : & ' a [ ty:: t ] ,
178
178
impl_dups : @RefCell < HashSet < DefId > > ,
179
- inherent_candidates : @mut ~[ Candidate ] ,
180
- extension_candidates : @mut ~[ Candidate ] ,
179
+ inherent_candidates : @RefCell < ~[ Candidate ] > ,
180
+ extension_candidates : @RefCell < ~[ Candidate ] > ,
181
181
deref_args : check:: DerefArgs ,
182
182
check_traits : CheckTraitsFlag ,
183
183
autoderef_receiver : AutoderefReceiverFlag ,
@@ -279,8 +279,8 @@ impl<'a> LookupContext<'a> {
279
279
// Candidate collection (see comment at start of file)
280
280
281
281
fn reset_candidates ( & self ) {
282
- * self . inherent_candidates = ~[ ] ;
283
- * self . extension_candidates = ~[ ] ;
282
+ self . inherent_candidates . set ( ~[ ] ) ;
283
+ self . extension_candidates . set ( ~[ ] ) ;
284
284
}
285
285
286
286
fn push_inherent_candidates ( & self , self_ty : ty:: t ) {
@@ -358,8 +358,10 @@ impl<'a> LookupContext<'a> {
358
358
let opt_impl_infos = trait_impls. get ( ) . find ( trait_did) ;
359
359
for impl_infos in opt_impl_infos. iter ( ) {
360
360
for impl_info in impl_infos. iter ( ) {
361
+ let mut extension_candidates =
362
+ self . extension_candidates . borrow_mut ( ) ;
361
363
self . push_candidates_from_impl (
362
- self . extension_candidates , * impl_info) ;
364
+ extension_candidates. get ( ) , * impl_info) ;
363
365
364
366
}
365
367
}
@@ -511,7 +513,9 @@ impl<'a> LookupContext<'a> {
511
513
pos, this_bound_idx) ;
512
514
513
515
debug ! ( "pushing inherent candidate for param: {:?}" , cand) ;
514
- self . inherent_candidates . push ( cand) ;
516
+ let mut inherent_candidates = self . inherent_candidates
517
+ . borrow_mut ( ) ;
518
+ inherent_candidates. get ( ) . push ( cand) ;
515
519
}
516
520
None => {
517
521
debug ! ( "trait doesn't contain method: {:?}" ,
@@ -533,8 +537,10 @@ impl<'a> LookupContext<'a> {
533
537
let opt_impl_infos = inherent_impls. get ( ) . find ( & did) ;
534
538
for impl_infos in opt_impl_infos. iter ( ) {
535
539
for impl_info in impl_infos. iter ( ) {
536
- self . push_candidates_from_impl (
537
- self . inherent_candidates , * impl_info) ;
540
+ let mut inherent_candidates = self . inherent_candidates
541
+ . borrow_mut ( ) ;
542
+ self . push_candidates_from_impl ( inherent_candidates. get ( ) ,
543
+ * impl_info) ;
538
544
}
539
545
}
540
546
}
@@ -828,15 +834,17 @@ impl<'a> LookupContext<'a> {
828
834
// existing code.
829
835
830
836
debug ! ( "searching inherent candidates" ) ;
831
- match self . consider_candidates ( rcvr_ty, self . inherent_candidates ) {
837
+ let mut inherent_candidates = self . inherent_candidates . borrow_mut ( ) ;
838
+ match self . consider_candidates ( rcvr_ty, inherent_candidates. get ( ) ) {
832
839
None => { }
833
840
Some ( mme) => {
834
841
return Some ( mme) ;
835
842
}
836
843
}
837
844
838
845
debug ! ( "searching extension candidates" ) ;
839
- match self . consider_candidates ( rcvr_ty, self . extension_candidates ) {
846
+ let mut extension_candidates = self . extension_candidates . borrow_mut ( ) ;
847
+ match self . consider_candidates ( rcvr_ty, extension_candidates. get ( ) ) {
840
848
None => {
841
849
return None ;
842
850
}
@@ -847,9 +855,9 @@ impl<'a> LookupContext<'a> {
847
855
}
848
856
849
857
fn consider_candidates ( & self ,
850
- rcvr_ty : ty:: t ,
851
- candidates : & mut ~[ Candidate ] )
852
- -> Option < method_map_entry > {
858
+ rcvr_ty : ty:: t ,
859
+ candidates : & mut ~[ Candidate ] )
860
+ -> Option < method_map_entry > {
853
861
// XXX(pcwalton): Do we need to clone here?
854
862
let relevant_candidates: ~[ Candidate ] =
855
863
candidates. iter ( ) . map ( |c| ( * c) . clone ( ) ) .
0 commit comments