@@ -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 ( ) {
@@ -2750,19 +2739,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2750
2739
if let Some ( def_id) = ptr. trait_ref . trait_def_id ( ) {
2751
2740
// Find the bounds on the trait with the lifetime that couldn't be met.
2752
2741
let bindings: Vec < Span > = elaborate_predicates_of ( self . tcx , def_id)
2753
- . filter_map ( |( pred, pred_span) | {
2754
- if let ty:: PredicateKind :: Clause ( clause) =
2755
- pred. kind ( ) . skip_binder ( )
2756
- && let ty:: ClauseKind :: TypeOutlives (
2757
- ty:: OutlivesPredicate ( _pred_ty, r) ,
2758
- ) = clause
2759
- && r == self . found_region
2760
- {
2761
- Some ( pred_span)
2762
- } else {
2763
- None
2764
- }
2765
- } )
2742
+ . filter_map ( filter_predicates ( self . found_region , |_| true ) )
2766
2743
. collect ( ) ;
2767
2744
if !bindings. is_empty ( ) {
2768
2745
self . lifetime_spans . insert ( ptr. span ) ;
@@ -2775,21 +2752,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
2775
2752
// definition of that associated item couldn't meet.
2776
2753
hir:: TyKind :: Path ( hir:: QPath :: Resolved ( Some ( _) , path) ) => {
2777
2754
self . pred_spans = elaborate_predicates_of ( self . tcx , path. res . def_id ( ) )
2778
- . filter_map ( |( pred, pred_span) | {
2779
- match pred. kind ( ) . skip_binder ( ) {
2780
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: TypeOutlives (
2781
- ty:: OutlivesPredicate (
2782
- // What should I filter this with?
2783
- _pred_ty,
2784
- r,
2785
- ) ,
2786
- ) ) if r == self . found_region => Some ( pred_span) ,
2787
- ty:: PredicateKind :: Clause ( ty:: ClauseKind :: RegionOutlives (
2788
- ty:: OutlivesPredicate ( _, r) ,
2789
- ) ) if r == self . found_region => Some ( pred_span) ,
2790
- _ => None ,
2791
- }
2792
- } )
2755
+ . filter_map ( filter_predicates ( self . found_region , |_| true ) )
2793
2756
. collect ( ) ;
2794
2757
}
2795
2758
_ => { }
0 commit comments