1- use std:: assert_matches:: debug_assert_matches;
21use std:: cell:: { Cell , RefCell } ;
32use std:: cmp:: max;
43use std:: ops:: Deref ;
@@ -16,7 +15,7 @@ use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk,
1615use rustc_infer:: traits:: ObligationCauseCode ;
1716use rustc_middle:: middle:: stability;
1817use 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} ;
2019use rustc_middle:: ty:: {
2120 self , AssocItem , AssocItemContainer , GenericArgs , GenericArgsRef , GenericParamDefKind ,
2221 ParamEnvAnd , Ty , TyCtxt , TypeVisitableExt , Upcast ,
@@ -803,8 +802,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
803802 ) ;
804803 }
805804 }
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 ) ;
808807 }
809808 ty:: Bool
810809 | ty:: Char
@@ -905,16 +904,18 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
905904 }
906905
907906 #[ 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 ) {
912908 let bounds = self . param_env . caller_bounds ( ) . iter ( ) . filter_map ( |predicate| {
913909 let bound_predicate = predicate. kind ( ) ;
914910 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+ }
918919 ty:: ClauseKind :: RegionOutlives ( _)
919920 | ty:: ClauseKind :: TypeOutlives ( _)
920921 | ty:: ClauseKind :: Projection ( _)
0 commit comments