@@ -104,6 +104,8 @@ pub trait TypeErrCtxtExt<'tcx> {
104
104
error : & SelectionError < ' tcx > ,
105
105
) ;
106
106
107
+ fn fn_arg_obligation ( & self , obligation : & PredicateObligation < ' tcx > ) -> bool ;
108
+
107
109
fn report_const_param_not_wf (
108
110
& self ,
109
111
ty : Ty < ' tcx > ,
@@ -434,20 +436,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
434
436
{
435
437
return ;
436
438
}
437
- if let ObligationCauseCode :: FunctionArgumentObligation {
438
- arg_hir_id,
439
- ..
440
- } = obligation. cause . code ( )
441
- && let Some ( Node :: Expr ( arg) ) = self . tcx . hir ( ) . find ( * arg_hir_id)
442
- && let arg = arg. peel_borrows ( )
443
- && let hir:: ExprKind :: Path ( hir:: QPath :: Resolved (
444
- None ,
445
- hir:: Path { res : hir:: def:: Res :: Local ( hir_id) , .. } ,
446
- ) ) = arg. kind
447
- && let Some ( Node :: Pat ( pat) ) = self . tcx . hir ( ) . find ( * hir_id)
448
- && let Some ( preds) = self . reported_trait_errors . borrow ( ) . get ( & pat. span )
449
- && preds. contains ( & obligation. predicate )
450
- {
439
+ if self . fn_arg_obligation ( & obligation) {
451
440
// Silence redundant errors on binding acccess that are already
452
441
// reported on the binding definition (#56607).
453
442
return ;
@@ -948,6 +937,26 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
948
937
err. emit ( ) ;
949
938
}
950
939
940
+ fn fn_arg_obligation ( & self , obligation : & PredicateObligation < ' tcx > ) -> bool {
941
+ if let ObligationCauseCode :: FunctionArgumentObligation {
942
+ arg_hir_id,
943
+ ..
944
+ } = obligation. cause . code ( )
945
+ && let Some ( Node :: Expr ( arg) ) = self . tcx . hir ( ) . find ( * arg_hir_id)
946
+ && let arg = arg. peel_borrows ( )
947
+ && let hir:: ExprKind :: Path ( hir:: QPath :: Resolved (
948
+ None ,
949
+ hir:: Path { res : hir:: def:: Res :: Local ( hir_id) , .. } ,
950
+ ) ) = arg. kind
951
+ && let Some ( Node :: Pat ( pat) ) = self . tcx . hir ( ) . find ( * hir_id)
952
+ && let Some ( preds) = self . reported_trait_errors . borrow ( ) . get ( & pat. span )
953
+ && preds. contains ( & obligation. predicate )
954
+ {
955
+ return true ;
956
+ }
957
+ false
958
+ }
959
+
951
960
fn report_const_param_not_wf (
952
961
& self ,
953
962
ty : Ty < ' tcx > ,
0 commit comments