1
- use std:: assert_matches:: debug_assert_matches;
2
1
use std:: cell:: { Cell , RefCell } ;
3
2
use std:: cmp:: max;
4
3
use std:: ops:: Deref ;
@@ -16,7 +15,7 @@ use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk,
16
15
use rustc_infer:: traits:: ObligationCauseCode ;
17
16
use rustc_middle:: middle:: stability;
18
17
use rustc_middle:: ty:: elaborate:: supertrait_def_ids;
19
- use rustc_middle:: ty:: fast_reject:: { DeepRejectCtxt , TreatParams , simplify_type} ;
18
+ use rustc_middle:: ty:: fast_reject:: { TreatParams , simplify_type} ;
20
19
use rustc_middle:: ty:: {
21
20
self , AssocItem , AssocItemContainer , GenericArgs , GenericArgsRef , GenericParamDefKind ,
22
21
ParamEnvAnd , Ty , TyCtxt , TypeVisitableExt , Upcast ,
@@ -803,8 +802,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
803
802
) ;
804
803
}
805
804
}
806
- ty:: Param ( _ ) => {
807
- self . assemble_inherent_candidates_from_param ( raw_self_ty ) ;
805
+ ty:: Param ( p ) => {
806
+ self . assemble_inherent_candidates_from_param ( p ) ;
808
807
}
809
808
ty:: Bool
810
809
| ty:: Char
@@ -905,16 +904,18 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
905
904
}
906
905
907
906
#[ instrument( level = "debug" , skip( self ) ) ]
908
- fn assemble_inherent_candidates_from_param ( & mut self , param_ty : Ty < ' tcx > ) {
909
- debug_assert_matches ! ( param_ty. kind( ) , ty:: Param ( _) ) ;
910
-
911
- let tcx = self . tcx ;
907
+ fn assemble_inherent_candidates_from_param ( & mut self , param_ty : ty:: ParamTy ) {
912
908
let bounds = self . param_env . caller_bounds ( ) . iter ( ) . filter_map ( |predicate| {
913
909
let bound_predicate = predicate. kind ( ) ;
914
910
match bound_predicate. skip_binder ( ) {
915
- ty:: ClauseKind :: Trait ( trait_predicate) => DeepRejectCtxt :: relate_rigid_rigid ( tcx)
916
- . types_may_unify ( param_ty, trait_predicate. trait_ref . self_ty ( ) )
917
- . then ( || bound_predicate. rebind ( trait_predicate. trait_ref ) ) ,
911
+ ty:: ClauseKind :: Trait ( trait_predicate) => {
912
+ match * trait_predicate. trait_ref . self_ty ( ) . kind ( ) {
913
+ ty:: Param ( p) if p == param_ty => {
914
+ Some ( bound_predicate. rebind ( trait_predicate. trait_ref ) )
915
+ }
916
+ _ => None ,
917
+ }
918
+ }
918
919
ty:: ClauseKind :: RegionOutlives ( _)
919
920
| ty:: ClauseKind :: TypeOutlives ( _)
920
921
| ty:: ClauseKind :: Projection ( _)
0 commit comments