Skip to content

Commit 65dddac

Browse files
committed
---
yaml --- r: 152177 b: refs/heads/try2 c: b387120 h: refs/heads/master i: 152175: 7d21676 v: v3
1 parent 6195c12 commit 65dddac

File tree

2 files changed

+11
-35
lines changed

2 files changed

+11
-35
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: 096f80e770efd586d614ee3b695c8461587cf9ec
8+
refs/heads/try2: b38712071efd09fd602cef6a11621db09672f990
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: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,13 +1026,7 @@ impl<'a> LookupContext<'a> {
10261026
fn consider_candidates(&self, rcvr_ty: ty::t,
10271027
candidates: &[Candidate])
10281028
-> Option<MethodCallee> {
1029-
// FIXME(pcwalton): Do we need to clone here?
1030-
let relevant_candidates: Vec<Candidate> =
1031-
candidates.iter().map(|c| (*c).clone()).
1032-
filter(|c| self.is_relevant(rcvr_ty, c)).collect();
1033-
1034-
let relevant_candidates =
1035-
self.merge_candidates(relevant_candidates.as_slice());
1029+
let relevant_candidates = self.filter_candidates(rcvr_ty, candidates);
10361030

10371031
if relevant_candidates.len() == 0 {
10381032
return None;
@@ -1069,22 +1063,16 @@ impl<'a> LookupContext<'a> {
10691063
Some(self.confirm_candidate(rcvr_ty, relevant_candidates.get(0)))
10701064
}
10711065

1072-
fn merge_candidates(&self, candidates: &[Candidate]) -> Vec<Candidate> {
1073-
let mut merged = Vec::new();
1074-
let mut i = 0;
1075-
while i < candidates.len() {
1076-
let candidate_a = &candidates[i];
1077-
1078-
let mut skip = false;
1066+
fn filter_candidates(&self, rcvr_ty: ty::t, candidates: &[Candidate]) -> Vec<Candidate> {
1067+
let mut relevant_candidates: Vec<Candidate> = Vec::new();
10791068

1080-
let mut j = i + 1;
1081-
while j < candidates.len() {
1082-
let candidate_b = &candidates[j];
1069+
for candidate_a in candidates.iter().filter(|&c| self.is_relevant(rcvr_ty, c)) {
1070+
// Skip this one if we already have one like it
1071+
if !relevant_candidates.iter().any(|candidate_b| {
10831072
debug!("attempting to merge {} and {}",
10841073
candidate_a.repr(self.tcx()),
10851074
candidate_b.repr(self.tcx()));
1086-
let candidates_same = match (&candidate_a.origin,
1087-
&candidate_b.origin) {
1075+
match (&candidate_a.origin, &candidate_b.origin) {
10881076
(&MethodParam(ref p1), &MethodParam(ref p2)) => {
10891077
let same_trait = p1.trait_id == p2.trait_id;
10901078
let same_method = p1.method_num == p2.method_num;
@@ -1095,25 +1083,13 @@ impl<'a> LookupContext<'a> {
10951083
same_trait && same_method && same_param
10961084
}
10971085
_ => false
1098-
};
1099-
if candidates_same {
1100-
skip = true;
1101-
break;
11021086
}
1103-
j += 1;
1104-
}
1105-
1106-
i += 1;
1107-
1108-
if skip {
1109-
// There are more than one of these and we need only one
1110-
continue;
1111-
} else {
1112-
merged.push(candidate_a.clone());
1087+
}) {
1088+
relevant_candidates.push(candidate_a.clone());
11131089
}
11141090
}
11151091

1116-
return merged;
1092+
relevant_candidates
11171093
}
11181094

11191095
fn confirm_candidate(&self, rcvr_ty: ty::t, candidate: &Candidate)

0 commit comments

Comments
 (0)