Skip to content

Commit df3ed39

Browse files
committed
---
yaml --- r: 94745 b: refs/heads/try c: 0afae85 h: refs/heads/master i: 94743: 1ed644a v: v3
1 parent 12dc06b commit df3ed39

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: 1a6c1e5d3238cd9817e72006735b59a578e0ac13
5+
refs/heads/try: 0afae85bc2889226fa4bb2f2a7e58947a58327dd
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/typeck/check/method.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ pub fn lookup(
142142
m_name: m_name,
143143
supplied_tps: supplied_tps,
144144
impl_dups: impl_dups,
145-
inherent_candidates: @mut ~[],
146-
extension_candidates: @mut ~[],
145+
inherent_candidates: @RefCell::new(~[]),
146+
extension_candidates: @RefCell::new(~[]),
147147
deref_args: deref_args,
148148
check_traits: check_traits,
149149
autoderef_receiver: autoderef_receiver,
@@ -176,8 +176,8 @@ pub struct LookupContext<'a> {
176176
m_name: ast::Name,
177177
supplied_tps: &'a [ty::t],
178178
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]>,
181181
deref_args: check::DerefArgs,
182182
check_traits: CheckTraitsFlag,
183183
autoderef_receiver: AutoderefReceiverFlag,
@@ -279,8 +279,8 @@ impl<'a> LookupContext<'a> {
279279
// Candidate collection (see comment at start of file)
280280

281281
fn reset_candidates(&self) {
282-
*self.inherent_candidates = ~[];
283-
*self.extension_candidates = ~[];
282+
self.inherent_candidates.set(~[]);
283+
self.extension_candidates.set(~[]);
284284
}
285285

286286
fn push_inherent_candidates(&self, self_ty: ty::t) {
@@ -358,8 +358,10 @@ impl<'a> LookupContext<'a> {
358358
let opt_impl_infos = trait_impls.get().find(trait_did);
359359
for impl_infos in opt_impl_infos.iter() {
360360
for impl_info in impl_infos.iter() {
361+
let mut extension_candidates =
362+
self.extension_candidates.borrow_mut();
361363
self.push_candidates_from_impl(
362-
self.extension_candidates, *impl_info);
364+
extension_candidates.get(), *impl_info);
363365

364366
}
365367
}
@@ -511,7 +513,9 @@ impl<'a> LookupContext<'a> {
511513
pos, this_bound_idx);
512514

513515
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);
515519
}
516520
None => {
517521
debug!("trait doesn't contain method: {:?}",
@@ -533,8 +537,10 @@ impl<'a> LookupContext<'a> {
533537
let opt_impl_infos = inherent_impls.get().find(&did);
534538
for impl_infos in opt_impl_infos.iter() {
535539
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);
538544
}
539545
}
540546
}
@@ -828,15 +834,17 @@ impl<'a> LookupContext<'a> {
828834
// existing code.
829835

830836
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()) {
832839
None => {}
833840
Some(mme) => {
834841
return Some(mme);
835842
}
836843
}
837844

838845
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()) {
840848
None => {
841849
return None;
842850
}
@@ -847,9 +855,9 @@ impl<'a> LookupContext<'a> {
847855
}
848856

849857
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> {
853861
// XXX(pcwalton): Do we need to clone here?
854862
let relevant_candidates: ~[Candidate] =
855863
candidates.iter().map(|c| (*c).clone()).

0 commit comments

Comments
 (0)