@@ -17,6 +17,21 @@ enum ClauseFlavor {
17
17
Const ,
18
18
}
19
19
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
+
20
35
impl < ' a , ' tcx > FnCtxt < ' a , ' tcx > {
21
36
pub ( crate ) fn adjust_fulfillment_error_for_expr_obligation (
22
37
& self ,
@@ -77,17 +92,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
77
92
_ => return false ,
78
93
} ;
79
94
80
- let find_param_matching = |matches : & dyn Fn ( ty :: ParamTerm ) -> bool | {
95
+ let find_param_matching = |matches : & dyn Fn ( ParamTerm ) -> bool | {
81
96
predicate_args. iter ( ) . find_map ( |arg| {
82
97
arg. walk ( ) . find_map ( |arg| {
83
98
if let ty:: GenericArgKind :: Type ( ty) = arg. kind ( )
84
99
&& let ty:: Param ( param_ty) = * ty. kind ( )
85
- && matches ( ty :: ParamTerm :: Ty ( param_ty) )
100
+ && matches ( ParamTerm :: Ty ( param_ty) )
86
101
{
87
102
Some ( arg)
88
103
} else if let ty:: GenericArgKind :: Const ( ct) = arg. kind ( )
89
104
&& let ty:: ConstKind :: Param ( param_ct) = ct. kind ( )
90
- && matches ( ty :: ParamTerm :: Const ( param_ct) )
105
+ && matches ( ParamTerm :: Const ( param_ct) )
91
106
{
92
107
Some ( arg)
93
108
} else {
@@ -106,14 +121,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
106
121
// from a trait or impl, for example.
107
122
let mut fallback_param_to_point_at = find_param_matching ( & |param_term| {
108
123
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 )
110
125
} ) ;
111
126
// Finally, the `Self` parameter is possibly the reason that the predicate
112
127
// is unsatisfied. This is less likely to be true for methods, because
113
128
// method probe means that we already kinda check that the predicates due
114
129
// to the `Self` type are true.
115
130
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 ) ,
117
132
) ;
118
133
119
134
// Finally, for ambiguity-related errors, we actually want to look
0 commit comments