1
1
use super :: suggest;
2
+ use super :: CandidateSource ;
2
3
use super :: MethodError ;
3
4
use super :: NoMatchData ;
4
- use super :: { CandidateSource , ImplSource , TraitSource } ;
5
5
6
6
use crate :: check:: FnCtxt ;
7
7
use crate :: errors:: MethodCallOnUnknownType ;
@@ -694,7 +694,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
694
694
for item in self . impl_or_trait_item ( impl_def_id) {
695
695
if !self . has_applicable_self ( & item) {
696
696
// No receiver declared. Not a candidate.
697
- self . record_static_candidate ( ImplSource ( impl_def_id) ) ;
697
+ self . record_static_candidate ( CandidateSource :: Impl ( impl_def_id) ) ;
698
698
continue ;
699
699
}
700
700
@@ -848,7 +848,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
848
848
debug ! ( "elaborate_bounds(bound_trait_ref={:?})" , bound_trait_ref) ;
849
849
for item in self . impl_or_trait_item ( bound_trait_ref. def_id ( ) ) {
850
850
if !self . has_applicable_self ( & item) {
851
- self . record_static_candidate ( TraitSource ( bound_trait_ref. def_id ( ) ) ) ;
851
+ self . record_static_candidate ( CandidateSource :: Trait ( bound_trait_ref. def_id ( ) ) ) ;
852
852
} else {
853
853
mk_cand ( self , bound_trait_ref, item) ;
854
854
}
@@ -946,7 +946,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
946
946
// Check whether `trait_def_id` defines a method with suitable name.
947
947
if !self . has_applicable_self ( & item) {
948
948
debug ! ( "method has inapplicable self" ) ;
949
- self . record_static_candidate ( TraitSource ( trait_def_id) ) ;
949
+ self . record_static_candidate ( CandidateSource :: Trait ( trait_def_id) ) ;
950
950
continue ;
951
951
}
952
952
@@ -1018,8 +1018,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1018
1018
Some ( Err ( MethodError :: Ambiguity ( v) ) ) => v
1019
1019
. into_iter ( )
1020
1020
. map ( |source| match source {
1021
- TraitSource ( id) => id,
1022
- ImplSource ( impl_id) => match tcx. trait_id_of_impl ( impl_id) {
1021
+ CandidateSource :: Trait ( id) => id,
1022
+ CandidateSource :: Impl ( impl_id) => match tcx. trait_id_of_impl ( impl_id) {
1023
1023
Some ( id) => id,
1024
1024
None => span_bug ! ( span, "found inherent method when looking at traits" ) ,
1025
1025
} ,
@@ -1417,8 +1417,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1417
1417
1418
1418
fn candidate_source ( & self , candidate : & Candidate < ' tcx > , self_ty : Ty < ' tcx > ) -> CandidateSource {
1419
1419
match candidate. kind {
1420
- InherentImplCandidate ( ..) => ImplSource ( candidate. item . container . id ( ) ) ,
1421
- ObjectCandidate | WhereClauseCandidate ( _) => TraitSource ( candidate. item . container . id ( ) ) ,
1420
+ InherentImplCandidate ( ..) => CandidateSource :: Impl ( candidate. item . container . id ( ) ) ,
1421
+ ObjectCandidate | WhereClauseCandidate ( _) => {
1422
+ CandidateSource :: Trait ( candidate. item . container . id ( ) )
1423
+ }
1422
1424
TraitCandidate ( trait_ref) => self . probe ( |_| {
1423
1425
let _ = self
1424
1426
. at ( & ObligationCause :: dummy ( ) , self . param_env )
@@ -1428,9 +1430,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1428
1430
Ok ( Some ( traits:: ImplSource :: UserDefined ( ref impl_data) ) ) => {
1429
1431
// If only a single impl matches, make the error message point
1430
1432
// to that impl.
1431
- ImplSource ( impl_data. impl_def_id )
1433
+ CandidateSource :: Impl ( impl_data. impl_def_id )
1432
1434
}
1433
- _ => TraitSource ( candidate. item . container . id ( ) ) ,
1435
+ _ => CandidateSource :: Trait ( candidate. item . container . id ( ) ) ,
1434
1436
}
1435
1437
} ) ,
1436
1438
}
0 commit comments