@@ -830,26 +830,26 @@ pub impl<'self> LookupContext<'self> {
830
830
}
831
831
832
832
fn search_for_method ( & self ,
833
- self_ty : ty:: t )
833
+ rcvr_ty : ty:: t )
834
834
-> Option < method_map_entry >
835
835
{
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 ) ) ;
837
837
let _indenter = indenter ( ) ;
838
838
839
839
// I am not sure that inherent methods should have higher
840
840
// priority, but it is necessary ATM to handle some of the
841
841
// existing code.
842
842
843
843
debug ! ( "searching inherent candidates" ) ;
844
- match self . consider_candidates ( self_ty , self . inherent_candidates ) {
844
+ match self . consider_candidates ( rcvr_ty , self . inherent_candidates ) {
845
845
None => { }
846
846
Some ( mme) => {
847
847
return Some ( mme) ;
848
848
}
849
849
}
850
850
851
851
debug ! ( "searching extension candidates" ) ;
852
- match self . consider_candidates ( self_ty , self . extension_candidates ) {
852
+ match self . consider_candidates ( rcvr_ty , self . extension_candidates ) {
853
853
None => {
854
854
return None ;
855
855
}
@@ -860,12 +860,12 @@ pub impl<'self> LookupContext<'self> {
860
860
}
861
861
862
862
fn consider_candidates ( & self ,
863
- self_ty : ty:: t ,
863
+ rcvr_ty : ty:: t ,
864
864
candidates : & mut ~[ Candidate ] )
865
865
-> Option < method_map_entry >
866
866
{
867
867
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) ) ;
869
869
870
870
let relevant_candidates = self . merge_candidates ( relevant_candidates) ;
871
871
@@ -882,7 +882,7 @@ pub impl<'self> LookupContext<'self> {
882
882
}
883
883
}
884
884
885
- Some ( self . confirm_candidate ( self_ty , & relevant_candidates[ 0 ] ) )
885
+ Some ( self . confirm_candidate ( rcvr_ty , & relevant_candidates[ 0 ] ) )
886
886
}
887
887
888
888
fn merge_candidates ( & self , candidates : & [ Candidate ] ) -> ~[ Candidate ] {
@@ -932,7 +932,7 @@ pub impl<'self> LookupContext<'self> {
932
932
}
933
933
934
934
fn confirm_candidate ( & self ,
935
- self_ty : ty:: t ,
935
+ rcvr_ty : ty:: t ,
936
936
candidate : & Candidate )
937
937
-> method_map_entry
938
938
{
@@ -1041,11 +1041,11 @@ pub impl<'self> LookupContext<'self> {
1041
1041
// nothing has changed in the meantime, this unification
1042
1042
// should never fail.
1043
1043
match self . fcx . mk_subty ( false , self . self_expr . span ,
1044
- self_ty , transformed_self_ty) {
1044
+ rcvr_ty , transformed_self_ty) {
1045
1045
result:: Ok ( _) => ( ) ,
1046
1046
result:: Err ( _) => {
1047
1047
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 ) ,
1049
1049
self . ty_to_str( transformed_self_ty) ) ) ;
1050
1050
}
1051
1051
}
@@ -1114,9 +1114,11 @@ pub impl<'self> LookupContext<'self> {
1114
1114
}
1115
1115
}
1116
1116
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) ) ;
1120
1122
1121
1123
// Check for calls to object methods. We resolve these differently.
1122
1124
//
@@ -1134,7 +1136,7 @@ pub impl<'self> LookupContext<'self> {
1134
1136
// an &@Trait receiver (wacky)
1135
1137
}
1136
1138
sty_box( * ) | sty_uniq( * ) => {
1137
- return self . fcx . can_mk_subty ( self_ty ,
1139
+ return self . fcx . can_mk_subty ( rcvr_ty ,
1138
1140
candidate. rcvr_ty ) . is_ok ( ) ;
1139
1141
}
1140
1142
} ;
@@ -1148,11 +1150,11 @@ pub impl<'self> LookupContext<'self> {
1148
1150
}
1149
1151
1150
1152
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 ( )
1152
1154
}
1153
1155
1154
1156
sty_region( _, m) => {
1155
- match ty:: get ( self_ty ) . sty {
1157
+ match ty:: get ( rcvr_ty ) . sty {
1156
1158
ty:: ty_rptr( _, mt) => {
1157
1159
mutability_matches ( mt. mutbl , m) &&
1158
1160
self . fcx . can_mk_subty ( mt. ty , candidate. rcvr_ty ) . is_ok ( )
@@ -1163,7 +1165,7 @@ pub impl<'self> LookupContext<'self> {
1163
1165
}
1164
1166
1165
1167
sty_box( m) => {
1166
- match ty:: get ( self_ty ) . sty {
1168
+ match ty:: get ( rcvr_ty ) . sty {
1167
1169
ty:: ty_box( mt) => {
1168
1170
mutability_matches ( mt. mutbl , m) &&
1169
1171
self . fcx . can_mk_subty ( mt. ty , candidate. rcvr_ty ) . is_ok ( )
@@ -1174,7 +1176,7 @@ pub impl<'self> LookupContext<'self> {
1174
1176
}
1175
1177
1176
1178
sty_uniq( m) => {
1177
- match ty:: get ( self_ty ) . sty {
1179
+ match ty:: get ( rcvr_ty ) . sty {
1178
1180
ty:: ty_uniq( mt) => {
1179
1181
mutability_matches ( mt. mutbl , m) &&
1180
1182
self . fcx . can_mk_subty ( mt. ty , candidate. rcvr_ty ) . is_ok ( )
0 commit comments