@@ -17,6 +17,21 @@ enum ClauseFlavor {
1717 Const ,
1818}
1919
20+ #[ derive( Copy , Clone , PartialEq , Eq , Debug ) ]
21+ enum ParamTerm {
22+ Ty ( ty:: ParamTy ) ,
23+ Const ( ty:: ParamConst ) ,
24+ }
25+
26+ impl ParamTerm {
27+ fn index ( self ) -> usize {
28+ match self {
29+ ParamTerm :: Ty ( ty) => ty. index as usize ,
30+ ParamTerm :: Const ( ct) => ct. index as usize ,
31+ }
32+ }
33+ }
34+
2035impl < ' a , ' tcx > FnCtxt < ' a , ' tcx > {
2136 pub ( crate ) fn adjust_fulfillment_error_for_expr_obligation (
2237 & self ,
@@ -77,17 +92,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7792 _ => return false ,
7893 } ;
7994
80- let find_param_matching = |matches : & dyn Fn ( ty :: ParamTerm ) -> bool | {
95+ let find_param_matching = |matches : & dyn Fn ( ParamTerm ) -> bool | {
8196 predicate_args. iter ( ) . find_map ( |arg| {
8297 arg. walk ( ) . find_map ( |arg| {
8398 if let ty:: GenericArgKind :: Type ( ty) = arg. kind ( )
8499 && let ty:: Param ( param_ty) = * ty. kind ( )
85- && matches ( ty :: ParamTerm :: Ty ( param_ty) )
100+ && matches ( ParamTerm :: Ty ( param_ty) )
86101 {
87102 Some ( arg)
88103 } else if let ty:: GenericArgKind :: Const ( ct) = arg. kind ( )
89104 && let ty:: ConstKind :: Param ( param_ct) = ct. kind ( )
90- && matches ( ty :: ParamTerm :: Const ( param_ct) )
105+ && matches ( ParamTerm :: Const ( param_ct) )
91106 {
92107 Some ( arg)
93108 } else {
@@ -106,14 +121,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
106121 // from a trait or impl, for example.
107122 let mut fallback_param_to_point_at = find_param_matching ( & |param_term| {
108123 self . tcx . parent ( generics. param_at ( param_term. index ( ) , self . tcx ) . def_id ) != def_id
109- && !matches ! ( param_term, ty :: ParamTerm :: Ty ( ty) if ty. name == kw:: SelfUpper )
124+ && !matches ! ( param_term, ParamTerm :: Ty ( ty) if ty. name == kw:: SelfUpper )
110125 } ) ;
111126 // Finally, the `Self` parameter is possibly the reason that the predicate
112127 // is unsatisfied. This is less likely to be true for methods, because
113128 // method probe means that we already kinda check that the predicates due
114129 // to the `Self` type are true.
115130 let mut self_param_to_point_at = find_param_matching (
116- & |param_term| matches ! ( param_term, ty :: ParamTerm :: Ty ( ty) if ty. name == kw:: SelfUpper ) ,
131+ & |param_term| matches ! ( param_term, ParamTerm :: Ty ( ty) if ty. name == kw:: SelfUpper ) ,
117132 ) ;
118133
119134 // Finally, for ambiguity-related errors, we actually want to look
0 commit comments