@@ -3147,7 +3147,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
3147
3147
err : & mut Diagnostic ,
3148
3148
parent_code : & ObligationCauseCode < ' tcx > ,
3149
3149
param_env : ty:: ParamEnv < ' tcx > ,
3150
- predicate : ty:: Predicate < ' tcx > ,
3150
+ failed_pred : ty:: Predicate < ' tcx > ,
3151
3151
call_hir_id : HirId ,
3152
3152
) {
3153
3153
let tcx = self . tcx ;
@@ -3183,31 +3183,28 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
3183
3183
3184
3184
if let ObligationCauseCode :: ExprBindingObligation ( def_id, _, _, idx) = parent_code. deref ( )
3185
3185
&& let Some ( node_substs) = typeck_results. node_substs_opt ( call_hir_id)
3186
- && let predicates = self . tcx . predicates_of ( def_id) . instantiate ( self . tcx , node_substs)
3187
- && let Some ( pred ) = predicates . predicates . get ( * idx)
3186
+ && let where_clauses = self . tcx . predicates_of ( def_id) . instantiate ( self . tcx , node_substs)
3187
+ && let Some ( where_pred ) = where_clauses . predicates . get ( * idx)
3188
3188
{
3189
- if let Some ( trait_pred ) = pred . to_opt_poly_trait_pred ( )
3190
- && let Some ( trait_predicate ) = predicate . to_opt_poly_trait_pred ( )
3189
+ if let Some ( where_pred ) = where_pred . to_opt_poly_trait_pred ( )
3190
+ && let Some ( failed_pred ) = failed_pred . to_opt_poly_trait_pred ( )
3191
3191
{
3192
3192
let mut c = CollectAllMismatches {
3193
3193
infcx : self . infcx ,
3194
3194
param_env,
3195
3195
errors : vec ! [ ] ,
3196
3196
} ;
3197
- if let Ok ( _) = c. relate ( trait_pred , trait_predicate ) {
3197
+ if let Ok ( _) = c. relate ( where_pred , failed_pred ) {
3198
3198
type_diffs = c. errors ;
3199
3199
}
3200
- } else if let ty:: PredicateKind :: Clause (
3201
- ty:: Clause :: Projection ( proj)
3202
- ) = pred. kind ( ) . skip_binder ( )
3203
- && let ty:: PredicateKind :: Clause (
3204
- ty:: Clause :: Projection ( projection)
3205
- ) = predicate. kind ( ) . skip_binder ( )
3200
+ } else if let Some ( where_pred) = where_pred. to_opt_poly_projection_pred ( )
3201
+ && let Some ( failed_pred) = failed_pred. to_opt_poly_projection_pred ( )
3202
+ && let Some ( found) = failed_pred. skip_binder ( ) . term . ty ( )
3206
3203
{
3207
3204
type_diffs = vec ! [
3208
3205
Sorts ( ty:: error:: ExpectedFound {
3209
- expected: self . tcx. mk_ty( ty:: Alias ( ty:: Projection , proj . projection_ty) ) ,
3210
- found: projection . term . ty ( ) . unwrap ( ) ,
3206
+ expected: self . tcx. mk_ty( ty:: Alias ( ty:: Projection , where_pred . skip_binder ( ) . projection_ty) ) ,
3207
+ found,
3211
3208
} ) ,
3212
3209
] ;
3213
3210
}
0 commit comments