@@ -53,7 +53,7 @@ use crate::errors::{self, ObligationCauseFailureCode, TypeErrorAdditionalDiags};
53
53
use crate :: infer;
54
54
use crate :: infer:: error_reporting:: nice_region_error:: find_anon_type:: find_anon_type;
55
55
use crate :: infer:: ExpectedFound ;
56
- use crate :: traits:: util:: elaborate_predicates_of;
56
+ use crate :: traits:: util:: { elaborate_predicates_of, filter_predicates } ;
57
57
use crate :: traits:: {
58
58
IfExpressionCause , MatchExpressionArmCause , ObligationCause , ObligationCauseCode ,
59
59
PredicateObligation ,
@@ -498,20 +498,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
498
498
self . tcx ,
499
499
generic_param_scope. into ( ) ,
500
500
) )
501
- . filter_map ( |( pred, pred_span) | {
502
- if let ty:: PredicateKind :: Clause ( clause) =
503
- pred. kind ( ) . skip_binder ( )
504
- && let ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate (
505
- _pred_ty,
506
- r,
507
- ) ) = clause
508
- && r. kind ( ) == ty:: ReStatic
509
- {
510
- Some ( pred_span)
511
- } else {
512
- None
513
- }
514
- } )
501
+ . filter_map ( filter_predicates ( self . tcx . lifetimes . re_static , |_| {
502
+ true
503
+ } ) )
515
504
. collect ( ) ;
516
505
517
506
if !spans. is_empty ( ) {
@@ -2761,19 +2750,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2761
2750
if let Some ( def_id) = ptr. trait_ref . trait_def_id ( ) {
2762
2751
// Find the bounds on the trait with the lifetime that couldn't be met.
2763
2752
let bindings: Vec < Span > = elaborate_predicates_of ( self . tcx , def_id)
2764
- . filter_map ( |( pred, pred_span) | {
2765
- if let ty:: PredicateKind :: Clause ( clause) =
2766
- pred. kind ( ) . skip_binder ( )
2767
- && let ty:: ClauseKind :: TypeOutlives (
2768
- ty:: OutlivesPredicate ( _pred_ty, r) ,
2769
- ) = clause
2770
- && r == self . found_region
2771
- {
2772
- Some ( pred_span)
2773
- } else {
2774
- None
2775
- }
2776
- } )
2753
+ . filter_map ( filter_predicates ( self . found_region , |_| true ) )
2777
2754
. collect ( ) ;
2778
2755
if !bindings. is_empty ( ) {
2779
2756
self . lifetime_spans . insert ( ptr. span ) ;
@@ -2786,21 +2763,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2786
2763
// definition of that associated item couldn't meet.
2787
2764
hir:: TyKind :: Path ( hir:: QPath :: Resolved ( Some ( _) , path) ) => {
2788
2765
self . pred_spans = elaborate_predicates_of ( self . tcx , path. res . def_id ( ) )
2789
- . filter_map ( |( pred, pred_span) | {
2790
- match pred. kind ( ) . skip_binder ( ) {
2791
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeOutlives (
2792
- ty:: OutlivesPredicate (
2793
- // What should I filter this with?
2794
- _pred_ty,
2795
- r,
2796
- ) ,
2797
- ) ) if r == self . found_region => Some ( pred_span) ,
2798
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: RegionOutlives (
2799
- ty:: OutlivesPredicate ( _, r) ,
2800
- ) ) if r == self . found_region => Some ( pred_span) ,
2801
- _ => None ,
2802
- }
2803
- } )
2766
+ . filter_map ( filter_predicates ( self . found_region , |_| true ) )
2804
2767
. collect ( ) ;
2805
2768
}
2806
2769
_ => { }
0 commit comments