@@ -634,8 +634,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
634
634
}
635
635
}
636
636
637
+ #[ instrument( level = "debug" , skip( self ) ) ]
637
638
fn assemble_probe ( & mut self , self_ty : & Canonical < ' tcx , QueryResponse < ' tcx , Ty < ' tcx > > > ) {
638
- debug ! ( "assemble_probe: self_ty={:?}" , self_ty) ;
639
639
let raw_self_ty = self_ty. value . value ;
640
640
match * raw_self_ty. kind ( ) {
641
641
ty:: Dynamic ( data, ..) if let Some ( p) = data. principal ( ) => {
@@ -713,13 +713,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
713
713
}
714
714
}
715
715
716
+ #[ instrument( level = "debug" , skip( self ) ) ]
716
717
fn assemble_inherent_impl_probe ( & mut self , impl_def_id : DefId ) {
717
718
if !self . impl_dups . insert ( impl_def_id) {
718
719
return ; // already visited
719
720
}
720
721
721
- debug ! ( "assemble_inherent_impl_probe {:?}" , impl_def_id) ;
722
-
723
722
for item in self . impl_or_trait_item ( impl_def_id) {
724
723
if !self . has_applicable_self ( & item) {
725
724
// No receiver declared. Not a candidate.
@@ -737,9 +736,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
737
736
}
738
737
}
739
738
739
+ #[ instrument( level = "debug" , skip( self ) ) ]
740
740
fn assemble_inherent_candidates_from_object ( & mut self , self_ty : Ty < ' tcx > ) {
741
- debug ! ( "assemble_inherent_candidates_from_object(self_ty={:?})" , self_ty) ;
742
-
743
741
let principal = match self_ty. kind ( ) {
744
742
ty:: Dynamic ( ref data, ..) => Some ( data) ,
745
743
_ => None ,
@@ -768,9 +766,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
768
766
} ) ;
769
767
}
770
768
769
+ #[ instrument( level = "debug" , skip( self ) ) ]
771
770
fn assemble_inherent_candidates_from_param ( & mut self , param_ty : ty:: ParamTy ) {
772
771
// FIXME: do we want to commit to this behavior for param bounds?
773
- debug ! ( "assemble_inherent_candidates_from_param(param_ty={:?})" , param_ty) ;
774
772
775
773
let bounds = self . param_env . caller_bounds ( ) . iter ( ) . filter_map ( |predicate| {
776
774
let bound_predicate = predicate. kind ( ) ;
@@ -826,6 +824,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
826
824
}
827
825
}
828
826
827
+ #[ instrument( level = "debug" , skip( self ) ) ]
829
828
fn assemble_extension_candidates_for_traits_in_scope ( & mut self ) {
830
829
let mut duplicates = FxHashSet :: default ( ) ;
831
830
let opt_applicable_traits = self . tcx . in_scope_traits ( self . scope_expr_id ) ;
@@ -842,6 +841,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
842
841
}
843
842
}
844
843
844
+ #[ instrument( level = "debug" , skip( self ) ) ]
845
845
fn assemble_extension_candidates_for_all_traits ( & mut self ) {
846
846
let mut duplicates = FxHashSet :: default ( ) ;
847
847
for trait_info in suggest:: all_traits ( self . tcx ) {
@@ -863,12 +863,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
863
863
}
864
864
}
865
865
866
+ #[ instrument( level = "debug" , skip( self ) ) ]
866
867
fn assemble_extension_candidates_for_trait (
867
868
& mut self ,
868
869
import_ids : & SmallVec < [ LocalDefId ; 1 ] > ,
869
870
trait_def_id : DefId ,
870
871
) {
871
- debug ! ( "assemble_extension_candidates_for_trait(trait_def_id={:?})" , trait_def_id) ;
872
872
let trait_args = self . fresh_args_for_item ( self . span , trait_def_id) ;
873
873
let trait_ref = ty:: TraitRef :: new ( self . tcx , trait_def_id, trait_args) ;
874
874
@@ -958,6 +958,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
958
958
///////////////////////////////////////////////////////////////////////////
959
959
// THE ACTUAL SEARCH
960
960
961
+ #[ instrument( level = "debug" , skip( self ) ) ]
961
962
fn pick ( mut self ) -> PickResult < ' tcx > {
962
963
assert ! ( self . method_name. is_some( ) ) ;
963
964
@@ -1386,6 +1387,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1386
1387
}
1387
1388
}
1388
1389
1390
+ #[ instrument( level = "trace" , skip( self , possibly_unsatisfied_predicates) , ret) ]
1389
1391
fn consider_probe (
1390
1392
& self ,
1391
1393
self_ty : Ty < ' tcx > ,
@@ -1415,15 +1417,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1415
1417
( xform_self_ty, xform_ret_ty) =
1416
1418
self . xform_self_ty ( probe. item , impl_ty, impl_args) ;
1417
1419
xform_self_ty = ocx. normalize ( cause, self . param_env , xform_self_ty) ;
1418
- // FIXME: Make this `ocx.sup` once we define opaques more eagerly.
1419
- match self . at ( cause, self . param_env ) . sup (
1420
- DefineOpaqueTypes :: No ,
1421
- xform_self_ty,
1422
- self_ty,
1423
- ) {
1424
- Ok ( infer_ok) => {
1425
- ocx. register_infer_ok_obligations ( infer_ok) ;
1426
- }
1420
+ match ocx. sup ( cause, self . param_env , xform_self_ty, self_ty) {
1421
+ Ok ( ( ) ) => { }
1427
1422
Err ( err) => {
1428
1423
debug ! ( "--> cannot relate self-types {:?}" , err) ;
1429
1424
return ProbeResult :: NoMatch ;
@@ -1484,19 +1479,23 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1484
1479
( xform_self_ty, xform_ret_ty) =
1485
1480
self . xform_self_ty ( probe. item , trait_ref. self_ty ( ) , trait_ref. args ) ;
1486
1481
xform_self_ty = ocx. normalize ( cause, self . param_env , xform_self_ty) ;
1487
- // FIXME: Make this `ocx.sup` once we define opaques more eagerly.
1488
- match self . at ( cause, self . param_env ) . sup (
1489
- DefineOpaqueTypes :: No ,
1490
- xform_self_ty,
1491
- self_ty,
1492
- ) {
1493
- Ok ( infer_ok) => {
1494
- ocx. register_infer_ok_obligations ( infer_ok) ;
1495
- }
1496
- Err ( err) => {
1497
- debug ! ( "--> cannot relate self-types {:?}" , err) ;
1482
+ match self_ty. kind ( ) {
1483
+ // HACK: opaque types will match anything for which their bounds hold.
1484
+ // Thus we need to prevent them from trying to match the `&_` autoref
1485
+ // candidates that get created for `&self` trait methods.
1486
+ ty:: Alias ( ty:: Opaque , alias_ty)
1487
+ if self . infcx . can_define_opaque_ty ( alias_ty. def_id )
1488
+ && !xform_self_ty. is_ty_var ( ) =>
1489
+ {
1498
1490
return ProbeResult :: NoMatch ;
1499
1491
}
1492
+ _ => match ocx. sup ( cause, self . param_env , xform_self_ty, self_ty) {
1493
+ Ok ( ( ) ) => { }
1494
+ Err ( err) => {
1495
+ debug ! ( "--> cannot relate self-types {:?}" , err) ;
1496
+ return ProbeResult :: NoMatch ;
1497
+ }
1498
+ } ,
1500
1499
}
1501
1500
let obligation = traits:: Obligation :: new (
1502
1501
self . tcx ,
@@ -1536,15 +1535,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1536
1535
( xform_self_ty, xform_ret_ty) =
1537
1536
self . xform_self_ty ( probe. item , trait_ref. self_ty ( ) , trait_ref. args ) ;
1538
1537
xform_self_ty = ocx. normalize ( cause, self . param_env , xform_self_ty) ;
1539
- // FIXME: Make this `ocx.sup` once we define opaques more eagerly.
1540
- match self . at ( cause, self . param_env ) . sup (
1541
- DefineOpaqueTypes :: No ,
1542
- xform_self_ty,
1543
- self_ty,
1544
- ) {
1545
- Ok ( infer_ok) => {
1546
- ocx. register_infer_ok_obligations ( infer_ok) ;
1547
- }
1538
+ match ocx. sup ( cause, self . param_env , xform_self_ty, self_ty) {
1539
+ Ok ( ( ) ) => { }
1548
1540
Err ( err) => {
1549
1541
debug ! ( "--> cannot relate self-types {:?}" , err) ;
1550
1542
return ProbeResult :: NoMatch ;
@@ -1665,6 +1657,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
1665
1657
/// Similarly to `probe_for_return_type`, this method attempts to find the best matching
1666
1658
/// candidate method where the method name may have been misspelled. Similarly to other
1667
1659
/// edit distance based suggestions, we provide at most one such suggestion.
1660
+ #[ instrument( level = "debug" , skip( self ) ) ]
1668
1661
pub ( crate ) fn probe_for_similar_candidate (
1669
1662
& mut self ,
1670
1663
) -> Result < Option < ty:: AssocItem > , MethodError < ' tcx > > {
0 commit comments