@@ -491,6 +491,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
491
491
}
492
492
493
493
fn reset ( & mut self ) {
494
+ debug ! ( "reset" ) ;
494
495
self . inherent_candidates . clear ( ) ;
495
496
self . extension_candidates . clear ( ) ;
496
497
self . impl_dups . clear ( ) ;
@@ -505,13 +506,16 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
505
506
candidate : Candidate < ' tcx > ,
506
507
is_inherent : bool )
507
508
{
509
+ debug ! ( "push_candidate: candidate={:?} is_inherent={:?}" , candidate, is_inherent) ;
508
510
let is_accessible = if let Some ( name) = self . method_name {
509
511
let item = candidate. item ;
510
512
let def_scope = self . tcx . adjust_ident ( name, item. container . id ( ) , self . body_id ) . 1 ;
511
513
item. vis . is_accessible_from ( def_scope, self . tcx )
512
514
} else {
513
515
true
514
516
} ;
517
+
518
+ debug ! ( "push_candidate: is_accessible={:?}" , is_accessible) ;
515
519
if is_accessible {
516
520
if is_inherent {
517
521
self . inherent_candidates . push ( candidate) ;
@@ -847,6 +851,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
847
851
}
848
852
849
853
fn assemble_extension_candidates_for_all_traits ( & mut self ) -> Result < ( ) , MethodError < ' tcx > > {
854
+ debug ! ( "assemble_extension_candidates_for_all_traits" ) ;
850
855
let mut duplicates = FxHashSet :: default ( ) ;
851
856
for trait_info in suggest:: all_traits ( self . tcx ) {
852
857
if duplicates. insert ( trait_info. def_id ) {
@@ -939,6 +944,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
939
944
// THE ACTUAL SEARCH
940
945
941
946
fn pick ( mut self ) -> PickResult < ' tcx > {
947
+ debug ! ( "pick: method_name={:?}" , self . method_name) ;
942
948
assert ! ( self . method_name. is_some( ) ) ;
943
949
944
950
if let Some ( r) = self . pick_core ( ) {
@@ -958,9 +964,13 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
958
964
self . assemble_extension_candidates_for_all_traits ( ) ?;
959
965
960
966
let out_of_scope_traits = match self . pick_core ( ) {
961
- Some ( Ok ( p) ) => vec ! [ p. item. container. id( ) ] ,
967
+ Some ( Ok ( p) ) => {
968
+ debug ! ( "pick: (ok) p={:?}" , p) ;
969
+ vec ! [ p. item. container. id( ) ]
970
+ } ,
962
971
//Some(Ok(p)) => p.iter().map(|p| p.item.container().id()).collect(),
963
972
Some ( Err ( MethodError :: Ambiguity ( v) ) ) => {
973
+ debug ! ( "pick: (ambiguity) v={:?}" , v) ;
964
974
v. into_iter ( )
965
975
. map ( |source| {
966
976
match source {
@@ -979,6 +989,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
979
989
. collect ( )
980
990
}
981
991
Some ( Err ( MethodError :: NoMatch ( NoMatchData { out_of_scope_traits : others, .. } ) ) ) => {
992
+ debug ! ( "pick: (no match) others={:?}" , others) ;
982
993
assert ! ( others. is_empty( ) ) ;
983
994
vec ! [ ]
984
995
}
@@ -990,6 +1001,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
990
1001
}
991
1002
let lev_candidate = self . probe_for_lev_candidate ( ) ?;
992
1003
1004
+ debug ! ( "pick: out_of_scope_traits={:?}" , out_of_scope_traits) ;
993
1005
Err ( MethodError :: NoMatch ( NoMatchData :: new ( static_candidates,
994
1006
unsatisfied_predicates,
995
1007
out_of_scope_traits,
@@ -1302,13 +1314,20 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
1302
1314
let predicate = trait_ref. to_predicate ( ) ;
1303
1315
let obligation =
1304
1316
traits:: Obligation :: new ( cause, self . param_env , predicate) ;
1317
+ debug ! (
1318
+ "consider_probe: predicate={:?} obligation={:?} trait_ref={:?}" ,
1319
+ predicate, obligation, trait_ref
1320
+ ) ;
1305
1321
if !self . predicate_may_hold ( & obligation) {
1322
+ debug ! ( "consider_probe: predicate did not hold" ) ;
1306
1323
if self . probe ( |_| self . select_trait_candidate ( trait_ref) . is_err ( ) ) {
1324
+ debug ! ( "consider_probe: select_trait_candidate.is_err=true" ) ;
1307
1325
// This candidate's primary obligation doesn't even
1308
1326
// select - don't bother registering anything in
1309
1327
// `potentially_unsatisfied_predicates`.
1310
1328
return ProbeResult :: NoMatch ;
1311
1329
} else {
1330
+ debug ! ( "consider_probe: nested subobligation" ) ;
1312
1331
// Some nested subobligation of this predicate
1313
1332
// failed.
1314
1333
//
0 commit comments