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