Skip to content

Commit 70e02cf

Browse files
committed
rustc: rename a method receiver type to rcvr_ty
1 parent 8d19f44 commit 70e02cf

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

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

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -830,26 +830,26 @@ pub impl<'self> LookupContext<'self> {
830830
}
831831

832832
fn search_for_method(&self,
833-
self_ty: ty::t)
833+
rcvr_ty: ty::t)
834834
-> Option<method_map_entry>
835835
{
836-
debug!("search_for_method(self_ty=%s)", self.ty_to_str(self_ty));
836+
debug!("search_for_method(rcvr_ty=%s)", self.ty_to_str(rcvr_ty));
837837
let _indenter = indenter();
838838

839839
// I am not sure that inherent methods should have higher
840840
// priority, but it is necessary ATM to handle some of the
841841
// existing code.
842842

843843
debug!("searching inherent candidates");
844-
match self.consider_candidates(self_ty, self.inherent_candidates) {
844+
match self.consider_candidates(rcvr_ty, self.inherent_candidates) {
845845
None => {}
846846
Some(mme) => {
847847
return Some(mme);
848848
}
849849
}
850850

851851
debug!("searching extension candidates");
852-
match self.consider_candidates(self_ty, self.extension_candidates) {
852+
match self.consider_candidates(rcvr_ty, self.extension_candidates) {
853853
None => {
854854
return None;
855855
}
@@ -860,12 +860,12 @@ pub impl<'self> LookupContext<'self> {
860860
}
861861

862862
fn consider_candidates(&self,
863-
self_ty: ty::t,
863+
rcvr_ty: ty::t,
864864
candidates: &mut ~[Candidate])
865865
-> Option<method_map_entry>
866866
{
867867
let relevant_candidates =
868-
candidates.filter_to_vec(|c| self.is_relevant(self_ty, c));
868+
candidates.filter_to_vec(|c| self.is_relevant(rcvr_ty, c));
869869

870870
let relevant_candidates = self.merge_candidates(relevant_candidates);
871871

@@ -882,7 +882,7 @@ pub impl<'self> LookupContext<'self> {
882882
}
883883
}
884884

885-
Some(self.confirm_candidate(self_ty, &relevant_candidates[0]))
885+
Some(self.confirm_candidate(rcvr_ty, &relevant_candidates[0]))
886886
}
887887

888888
fn merge_candidates(&self, candidates: &[Candidate]) -> ~[Candidate] {
@@ -932,7 +932,7 @@ pub impl<'self> LookupContext<'self> {
932932
}
933933

934934
fn confirm_candidate(&self,
935-
self_ty: ty::t,
935+
rcvr_ty: ty::t,
936936
candidate: &Candidate)
937937
-> method_map_entry
938938
{
@@ -1041,11 +1041,11 @@ pub impl<'self> LookupContext<'self> {
10411041
// nothing has changed in the meantime, this unification
10421042
// should never fail.
10431043
match self.fcx.mk_subty(false, self.self_expr.span,
1044-
self_ty, transformed_self_ty) {
1044+
rcvr_ty, transformed_self_ty) {
10451045
result::Ok(_) => (),
10461046
result::Err(_) => {
10471047
self.bug(fmt!("%s was a subtype of %s but now is not?",
1048-
self.ty_to_str(self_ty),
1048+
self.ty_to_str(rcvr_ty),
10491049
self.ty_to_str(transformed_self_ty)));
10501050
}
10511051
}
@@ -1114,9 +1114,11 @@ pub impl<'self> LookupContext<'self> {
11141114
}
11151115
}
11161116

1117-
fn is_relevant(&self, self_ty: ty::t, candidate: &Candidate) -> bool {
1118-
debug!("is_relevant(self_ty=%s, candidate=%s)",
1119-
self.ty_to_str(self_ty), self.cand_to_str(candidate));
1117+
// `rcvr_ty` is the type of the expression. It may be a subtype of a
1118+
// candidate method's `self_ty`.
1119+
fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
1120+
debug!("is_relevant(rcvr_ty=%s, candidate=%s)",
1121+
self.ty_to_str(rcvr_ty), self.cand_to_str(candidate));
11201122

11211123
// Check for calls to object methods. We resolve these differently.
11221124
//
@@ -1134,7 +1136,7 @@ pub impl<'self> LookupContext<'self> {
11341136
// an &@Trait receiver (wacky)
11351137
}
11361138
sty_box(*) | sty_uniq(*) => {
1137-
return self.fcx.can_mk_subty(self_ty,
1139+
return self.fcx.can_mk_subty(rcvr_ty,
11381140
candidate.rcvr_ty).is_ok();
11391141
}
11401142
};
@@ -1148,11 +1150,11 @@ pub impl<'self> LookupContext<'self> {
11481150
}
11491151

11501152
sty_value => {
1151-
self.fcx.can_mk_subty(self_ty, candidate.rcvr_ty).is_ok()
1153+
self.fcx.can_mk_subty(rcvr_ty, candidate.rcvr_ty).is_ok()
11521154
}
11531155

11541156
sty_region(_, m) => {
1155-
match ty::get(self_ty).sty {
1157+
match ty::get(rcvr_ty).sty {
11561158
ty::ty_rptr(_, mt) => {
11571159
mutability_matches(mt.mutbl, m) &&
11581160
self.fcx.can_mk_subty(mt.ty, candidate.rcvr_ty).is_ok()
@@ -1163,7 +1165,7 @@ pub impl<'self> LookupContext<'self> {
11631165
}
11641166

11651167
sty_box(m) => {
1166-
match ty::get(self_ty).sty {
1168+
match ty::get(rcvr_ty).sty {
11671169
ty::ty_box(mt) => {
11681170
mutability_matches(mt.mutbl, m) &&
11691171
self.fcx.can_mk_subty(mt.ty, candidate.rcvr_ty).is_ok()
@@ -1174,7 +1176,7 @@ pub impl<'self> LookupContext<'self> {
11741176
}
11751177

11761178
sty_uniq(m) => {
1177-
match ty::get(self_ty).sty {
1179+
match ty::get(rcvr_ty).sty {
11781180
ty::ty_uniq(mt) => {
11791181
mutability_matches(mt.mutbl, m) &&
11801182
self.fcx.can_mk_subty(mt.ty, candidate.rcvr_ty).is_ok()

0 commit comments

Comments
 (0)