@@ -247,7 +247,7 @@ impl<'self> LookupContext<'self> {
247
247
self . search_for_autosliced_method ( self_ty, autoderefs)
248
248
}
249
249
250
- pub fn deref ( & self , ty : ty:: t )
250
+ fn deref ( & self , ty : ty:: t )
251
251
-> Option < ty:: t > {
252
252
match ty:: deref ( self . tcx ( ) , ty, false ) {
253
253
None => None ,
@@ -262,7 +262,12 @@ impl<'self> LookupContext<'self> {
262
262
// ______________________________________________________________________
263
263
// Candidate collection (see comment at start of file)
264
264
265
- pub fn push_inherent_candidates ( & self , self_ty : ty:: t ) {
265
+ fn reset_candidates ( & self ) {
266
+ * self . inherent_candidates = ~[ ] ;
267
+ * self . extension_candidates = ~[ ] ;
268
+ }
269
+
270
+ fn push_inherent_candidates ( & self , self_ty : ty:: t ) {
266
271
/*!
267
272
* Collect all inherent candidates into
268
273
* `self.inherent_candidates`. See comment at the start of
@@ -403,7 +408,7 @@ impl<'self> LookupContext<'self> {
403
408
}
404
409
405
410
406
- pub fn push_inherent_candidates_from_self ( & self ,
411
+ fn push_inherent_candidates_from_self ( & self ,
407
412
self_ty : ty:: t ,
408
413
did : def_id ) {
409
414
let tcx = self . tcx ( ) ;
@@ -413,7 +418,7 @@ impl<'self> LookupContext<'self> {
413
418
self_ty, & [ trait_ref] , param_self) ;
414
419
}
415
420
416
- pub fn push_inherent_candidates_from_bounds ( & self ,
421
+ fn push_inherent_candidates_from_bounds ( & self ,
417
422
self_ty : ty:: t ,
418
423
bounds : & [ @TraitRef ] ,
419
424
param : param_index ) {
@@ -459,7 +464,7 @@ impl<'self> LookupContext<'self> {
459
464
}
460
465
461
466
462
- pub fn push_inherent_impl_candidates_for_type ( & self , did : def_id ) {
467
+ fn push_inherent_impl_candidates_for_type ( & self , did : def_id ) {
463
468
let opt_impl_infos = self . tcx ( ) . inherent_impls . find ( & did) ;
464
469
for impl_infos in opt_impl_infos. iter ( ) {
465
470
for impl_info in impl_infos. iter ( ) {
@@ -469,7 +474,7 @@ impl<'self> LookupContext<'self> {
469
474
}
470
475
}
471
476
472
- pub fn push_candidates_from_impl ( & self ,
477
+ fn push_candidates_from_impl ( & self ,
473
478
candidates : & mut ~[ Candidate ] ,
474
479
impl_info : & ty:: Impl ) {
475
480
if !self . impl_dups . insert ( impl_info. did ) {
@@ -512,7 +517,7 @@ impl<'self> LookupContext<'self> {
512
517
// ______________________________________________________________________
513
518
// Candidate selection (see comment at start of file)
514
519
515
- pub fn search_for_autoderefd_method ( & self ,
520
+ fn search_for_autoderefd_method ( & self ,
516
521
self_ty : ty:: t ,
517
522
autoderefs : uint )
518
523
-> Option < method_map_entry > {
@@ -531,12 +536,11 @@ impl<'self> LookupContext<'self> {
531
536
}
532
537
}
533
538
534
- pub fn consider_reborrow ( & self ,
539
+ fn consider_reborrow ( & self ,
535
540
self_ty : ty:: t ,
536
541
autoderefs : uint )
537
542
-> ( ty:: t , ty:: AutoAdjustment ) {
538
543
/*!
539
- *
540
544
* In the event that we are invoking a method with a receiver
541
545
* of a borrowed type like `&T`, `&mut T`, or `&mut [T]`,
542
546
* we will "reborrow" the receiver implicitly. For example, if
@@ -598,7 +602,7 @@ impl<'self> LookupContext<'self> {
598
602
}
599
603
}
600
604
601
- pub fn search_for_autosliced_method ( & self ,
605
+ fn search_for_autosliced_method ( & self ,
602
606
self_ty : ty:: t ,
603
607
autoderefs : uint )
604
608
-> Option < method_map_entry > {
@@ -664,7 +668,7 @@ impl<'self> LookupContext<'self> {
664
668
}
665
669
}
666
670
667
- pub fn search_for_autoptrd_method ( & self , self_ty : ty:: t , autoderefs : uint )
671
+ fn search_for_autoptrd_method ( & self , self_ty : ty:: t , autoderefs : uint )
668
672
-> Option < method_map_entry > {
669
673
/*!
670
674
*
@@ -696,7 +700,7 @@ impl<'self> LookupContext<'self> {
696
700
}
697
701
}
698
702
699
- pub fn search_for_some_kind_of_autorefd_method (
703
+ fn search_for_some_kind_of_autorefd_method (
700
704
& self ,
701
705
kind : & fn ( Region , ast:: mutability ) -> ty:: AutoRef ,
702
706
autoderefs : uint ,
@@ -725,7 +729,7 @@ impl<'self> LookupContext<'self> {
725
729
return None ;
726
730
}
727
731
728
- pub fn search_for_method ( & self , rcvr_ty : ty:: t )
732
+ fn search_for_method ( & self , rcvr_ty : ty:: t )
729
733
-> Option < method_map_entry > {
730
734
debug ! ( "search_for_method(rcvr_ty=%s)" , self . ty_to_str( rcvr_ty) ) ;
731
735
let _indenter = indenter ( ) ;
@@ -753,7 +757,7 @@ impl<'self> LookupContext<'self> {
753
757
}
754
758
}
755
759
756
- pub fn consider_candidates ( & self ,
760
+ fn consider_candidates ( & self ,
757
761
rcvr_ty : ty:: t ,
758
762
candidates : & mut ~[ Candidate ] )
759
763
-> Option < method_map_entry > {
@@ -780,7 +784,7 @@ impl<'self> LookupContext<'self> {
780
784
Some ( self . confirm_candidate ( rcvr_ty, & relevant_candidates[ 0 ] ) )
781
785
}
782
786
783
- pub fn merge_candidates ( & self , candidates : & [ Candidate ] ) -> ~[ Candidate ] {
787
+ fn merge_candidates ( & self , candidates : & [ Candidate ] ) -> ~[ Candidate ] {
784
788
let mut merged = ~[ ] ;
785
789
let mut i = 0 ;
786
790
while i < candidates. len ( ) {
@@ -826,7 +830,7 @@ impl<'self> LookupContext<'self> {
826
830
return merged;
827
831
}
828
832
829
- pub fn confirm_candidate ( & self , rcvr_ty : ty:: t , candidate : & Candidate )
833
+ fn confirm_candidate ( & self , rcvr_ty : ty:: t , candidate : & Candidate )
830
834
-> method_map_entry {
831
835
let tcx = self . tcx ( ) ;
832
836
let fty = self . fn_ty_from_origin ( & candidate. origin ) ;
@@ -1108,7 +1112,7 @@ impl<'self> LookupContext<'self> {
1108
1112
}
1109
1113
}
1110
1114
1111
- pub fn fn_ty_from_origin ( & self , origin : & method_origin ) -> ty:: t {
1115
+ fn fn_ty_from_origin ( & self , origin : & method_origin ) -> ty:: t {
1112
1116
return match * origin {
1113
1117
method_static( did) => {
1114
1118
ty:: lookup_item_type ( self . tcx ( ) , did) . ty
@@ -1129,7 +1133,7 @@ impl<'self> LookupContext<'self> {
1129
1133
}
1130
1134
}
1131
1135
1132
- pub fn report_candidate ( & self , idx : uint , origin : & method_origin ) {
1136
+ fn report_candidate ( & self , idx : uint , origin : & method_origin ) {
1133
1137
match * origin {
1134
1138
method_static( impl_did) => {
1135
1139
self . report_static_candidate ( idx, impl_did)
@@ -1143,7 +1147,7 @@ impl<'self> LookupContext<'self> {
1143
1147
}
1144
1148
}
1145
1149
1146
- pub fn report_static_candidate ( & self , idx : uint , did : def_id ) {
1150
+ fn report_static_candidate ( & self , idx : uint , did : def_id ) {
1147
1151
let span = if did. crate == ast:: LOCAL_CRATE {
1148
1152
match self . tcx ( ) . items . find ( & did. node ) {
1149
1153
Some ( & ast_map:: node_method( m, _, _) ) => m. span ,
@@ -1159,15 +1163,15 @@ impl<'self> LookupContext<'self> {
1159
1163
ty:: item_path_str( self . tcx( ) , did) ) ) ;
1160
1164
}
1161
1165
1162
- pub fn report_param_candidate ( & self , idx : uint , did : def_id ) {
1166
+ fn report_param_candidate ( & self , idx : uint , did : def_id ) {
1163
1167
self . tcx ( ) . sess . span_note (
1164
1168
self . expr . span ,
1165
1169
fmt ! ( "candidate #%u derives from the bound `%s`" ,
1166
1170
( idx+1 u) ,
1167
1171
ty:: item_path_str( self . tcx( ) , did) ) ) ;
1168
1172
}
1169
1173
1170
- pub fn report_trait_candidate ( & self , idx : uint , did : def_id ) {
1174
+ fn report_trait_candidate ( & self , idx : uint , did : def_id ) {
1171
1175
self . tcx ( ) . sess . span_note (
1172
1176
self . expr . span ,
1173
1177
fmt ! ( "candidate #%u derives from the type of the receiver, \
@@ -1176,31 +1180,31 @@ impl<'self> LookupContext<'self> {
1176
1180
ty:: item_path_str( self . tcx( ) , did) ) ) ;
1177
1181
}
1178
1182
1179
- pub fn infcx ( & self ) -> @mut infer:: InferCtxt {
1183
+ fn infcx ( & self ) -> @mut infer:: InferCtxt {
1180
1184
self . fcx . inh . infcx
1181
1185
}
1182
1186
1183
- pub fn tcx ( & self ) -> ty:: ctxt {
1187
+ fn tcx ( & self ) -> ty:: ctxt {
1184
1188
self . fcx . tcx ( )
1185
1189
}
1186
1190
1187
- pub fn ty_to_str ( & self , t : ty:: t ) -> ~str {
1191
+ fn ty_to_str ( & self , t : ty:: t ) -> ~str {
1188
1192
self . fcx . infcx ( ) . ty_to_str ( t)
1189
1193
}
1190
1194
1191
- pub fn cand_to_str ( & self , cand : & Candidate ) -> ~str {
1195
+ fn cand_to_str ( & self , cand : & Candidate ) -> ~str {
1192
1196
fmt ! ( "Candidate(rcvr_ty=%s, rcvr_substs=%s, origin=%?)" ,
1193
- self . ty_to_str ( cand . rcvr_ty ) ,
1197
+ cand . rcvr_match_condition . repr ( self . tcx ( ) ) ,
1194
1198
ty:: substs_to_str( self . tcx( ) , & cand. rcvr_substs) ,
1195
1199
cand. origin)
1196
1200
}
1197
1201
1198
- pub fn did_to_str ( & self , did : def_id ) -> ~str {
1202
+ fn did_to_str ( & self , did : def_id ) -> ~str {
1199
1203
ty:: item_path_str ( self . tcx ( ) , did)
1200
1204
}
1201
1205
1202
- pub fn bug ( & self , s : ~str ) -> ! {
1203
- self . tcx ( ) . sess . bug ( s)
1206
+ fn bug ( & self , s : ~str ) -> ! {
1207
+ self . tcx ( ) . sess . span_bug ( self . self_expr . span , s)
1204
1208
}
1205
1209
}
1206
1210
0 commit comments