@@ -651,8 +651,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
651
651
}
652
652
}
653
653
654
+ #[ instrument( level = "debug" , skip( self ) ) ]
654
655
fn assemble_probe ( & mut self , self_ty : & Canonical < ' tcx , QueryResponse < ' tcx , Ty < ' tcx > > > ) {
655
- debug ! ( "assemble_probe: self_ty={:?}" , self_ty) ;
656
656
let raw_self_ty = self_ty. value . value ;
657
657
match * raw_self_ty. kind ( ) {
658
658
ty:: Dynamic ( data, ..) if let Some ( p) = data. principal ( ) => {
@@ -730,13 +730,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
730
730
}
731
731
}
732
732
733
+ #[ instrument( level = "debug" , skip( self ) ) ]
733
734
fn assemble_inherent_impl_probe ( & mut self , impl_def_id : DefId ) {
734
735
if !self . impl_dups . insert ( impl_def_id) {
735
736
return ; // already visited
736
737
}
737
738
738
- debug ! ( "assemble_inherent_impl_probe {:?}" , impl_def_id) ;
739
-
740
739
for item in self . impl_or_trait_item ( impl_def_id) {
741
740
if !self . has_applicable_self ( & item) {
742
741
// No receiver declared. Not a candidate.
@@ -786,9 +785,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
786
785
}
787
786
}
788
787
788
+ #[ instrument( level = "debug" , skip( self ) ) ]
789
789
fn assemble_inherent_candidates_from_object ( & mut self , self_ty : Ty < ' tcx > ) {
790
- debug ! ( "assemble_inherent_candidates_from_object(self_ty={:?})" , self_ty) ;
791
-
792
790
let principal = match self_ty. kind ( ) {
793
791
ty:: Dynamic ( ref data, ..) => Some ( data) ,
794
792
_ => None ,
@@ -835,9 +833,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
835
833
} ) ;
836
834
}
837
835
836
+ #[ instrument( level = "debug" , skip( self ) ) ]
838
837
fn assemble_inherent_candidates_from_param ( & mut self , param_ty : ty:: ParamTy ) {
839
838
// FIXME: do we want to commit to this behavior for param bounds?
840
- debug ! ( "assemble_inherent_candidates_from_param(param_ty={:?})" , param_ty) ;
841
839
842
840
let bounds = self . param_env . caller_bounds ( ) . iter ( ) . filter_map ( |predicate| {
843
841
let bound_predicate = predicate. kind ( ) ;
@@ -904,6 +902,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
904
902
}
905
903
}
906
904
905
+ #[ instrument( level = "debug" , skip( self ) ) ]
907
906
fn assemble_extension_candidates_for_traits_in_scope ( & mut self ) {
908
907
let mut duplicates = FxHashSet :: default ( ) ;
909
908
let opt_applicable_traits = self . tcx . in_scope_traits ( self . scope_expr_id ) ;
@@ -920,6 +919,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
920
919
}
921
920
}
922
921
922
+ #[ instrument( level = "debug" , skip( self ) ) ]
923
923
fn assemble_extension_candidates_for_all_traits ( & mut self ) {
924
924
let mut duplicates = FxHashSet :: default ( ) ;
925
925
for trait_info in suggest:: all_traits ( self . tcx ) {
@@ -956,12 +956,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
956
956
}
957
957
}
958
958
959
+ #[ instrument( level = "debug" , skip( self ) ) ]
959
960
fn assemble_extension_candidates_for_trait (
960
961
& mut self ,
961
962
import_ids : & SmallVec < [ LocalDefId ; 1 ] > ,
962
963
trait_def_id : DefId ,
963
964
) {
964
- debug ! ( "assemble_extension_candidates_for_trait(trait_def_id={:?})" , trait_def_id) ;
965
965
let trait_args = self . fresh_args_for_item ( self . span , trait_def_id) ;
966
966
let trait_ref = ty:: TraitRef :: new ( self . tcx , trait_def_id, trait_args) ;
967
967
@@ -1066,6 +1066,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1066
1066
///////////////////////////////////////////////////////////////////////////
1067
1067
// THE ACTUAL SEARCH
1068
1068
1069
+ #[ instrument( level = "debug" , skip( self ) ) ]
1069
1070
fn pick ( mut self ) -> PickResult < ' tcx > {
1070
1071
assert ! ( self . method_name. is_some( ) ) ;
1071
1072
@@ -1474,6 +1475,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1474
1475
}
1475
1476
}
1476
1477
1478
+ #[ instrument( level = "trace" , skip( self , possibly_unsatisfied_predicates) , ret) ]
1477
1479
fn consider_probe (
1478
1480
& self ,
1479
1481
self_ty : Ty < ' tcx > ,
@@ -1484,20 +1486,29 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1484
1486
Option < ObligationCause < ' tcx > > ,
1485
1487
) > ,
1486
1488
) -> ProbeResult {
1487
- debug ! ( "consider_probe: self_ty={:?} probe={:?}" , self_ty, probe) ;
1488
-
1489
1489
self . probe ( |_| {
1490
1490
// First check that the self type can be related.
1491
- let sub_obligations = match self . at ( & ObligationCause :: dummy ( ) , self . param_env ) . sup (
1492
- DefineOpaqueTypes :: No ,
1493
- probe . xform_self_ty ,
1494
- self_ty ,
1495
- ) {
1496
- Ok ( InferOk { obligations , value : ( ) } ) => obligations ,
1497
- Err ( err ) => {
1498
- debug ! ( "--> cannot relate self-types {:?}" , err ) ;
1491
+ let sub_obligations = match self_ty . kind ( ) {
1492
+ // HACK: opaque types will match anything for which their bounds hold.
1493
+ // Thus we need to prevent them from trying to match the `&_` autoref
1494
+ // candidates that get created for `&self` trait methods.
1495
+ ty :: Alias ( ty :: Opaque , alias_ty )
1496
+ if self . infcx . can_define_opaque_ty ( alias_ty . def_id )
1497
+ && !probe . xform_self_ty . is_ty_var ( ) =>
1498
+ {
1499
1499
return ProbeResult :: NoMatch ;
1500
1500
}
1501
+ _ => match self . at ( & ObligationCause :: dummy ( ) , self . param_env ) . sup (
1502
+ DefineOpaqueTypes :: Yes ,
1503
+ probe. xform_self_ty ,
1504
+ self_ty,
1505
+ ) {
1506
+ Ok ( InferOk { obligations, value : ( ) } ) => obligations,
1507
+ Err ( err) => {
1508
+ debug ! ( "--> cannot relate self-types {:?}" , err) ;
1509
+ return ProbeResult :: NoMatch ;
1510
+ }
1511
+ } ,
1501
1512
} ;
1502
1513
1503
1514
let mut result = ProbeResult :: Match ;
@@ -1755,6 +1766,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1755
1766
/// Similarly to `probe_for_return_type`, this method attempts to find the best matching
1756
1767
/// candidate method where the method name may have been misspelled. Similarly to other
1757
1768
/// edit distance based suggestions, we provide at most one such suggestion.
1769
+ #[ instrument( level = "debug" , skip( self ) ) ]
1758
1770
pub ( crate ) fn probe_for_similar_candidate (
1759
1771
& mut self ,
1760
1772
) -> Result < Option < ty:: AssocItem > , MethodError < ' tcx > > {
0 commit comments