Skip to content

Commit 7bff1cb

Browse files
committed
---
yaml --- r: 147697 b: refs/heads/try2 c: 0afae85 h: refs/heads/master i: 147695: 0c79be4 v: v3
1 parent 2b7a80a commit 7bff1cb

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 1a6c1e5d3238cd9817e72006735b59a578e0ac13
8+
refs/heads/try2: 0afae85bc2889226fa4bb2f2a7e58947a58327dd
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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)