@@ -1924,14 +1924,13 @@ declare_lint_pass!(ExplicitOutlivesRequirements => [EXPLICIT_OUTLIVES_REQUIREMEN
19241924impl ExplicitOutlivesRequirements {
19251925 fn lifetimes_outliving_lifetime < ' tcx > (
19261926 tcx : TyCtxt < ' tcx > ,
1927- inferred_outlives : & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] ,
1927+ inferred_outlives : impl Iterator < Item = & ' tcx ( ty:: Clause < ' tcx > , Span ) > ,
19281928 item : DefId ,
19291929 lifetime : DefId ,
19301930 ) -> Vec < ty:: Region < ' tcx > > {
19311931 let item_generics = tcx. generics_of ( item) ;
19321932
19331933 inferred_outlives
1934- . iter ( )
19351934 . filter_map ( |( clause, _) | match clause. kind ( ) . skip_binder ( ) {
19361935 ty:: ClauseKind :: RegionOutlives ( ty:: OutlivesPredicate ( a, b) ) => match * a {
19371936 ty:: ReEarlyParam ( ebr)
@@ -1947,11 +1946,10 @@ impl ExplicitOutlivesRequirements {
19471946 }
19481947
19491948 fn lifetimes_outliving_type < ' tcx > (
1950- inferred_outlives : & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] ,
1949+ inferred_outlives : impl Iterator < Item = & ' tcx ( ty:: Clause < ' tcx > , Span ) > ,
19511950 index : u32 ,
19521951 ) -> Vec < ty:: Region < ' tcx > > {
19531952 inferred_outlives
1954- . iter ( )
19551953 . filter_map ( |( clause, _) | match clause. kind ( ) . skip_binder ( ) {
19561954 ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( a, b) ) => {
19571955 a. is_param ( index) . then_some ( b)
@@ -2094,7 +2092,11 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
20942092 (
20952093 Self :: lifetimes_outliving_lifetime (
20962094 cx. tcx ,
2097- inferred_outlives,
2095+ // don't warn if the inferred span actually came from the predicate we're looking at
2096+ // this happens if the type is recursively defined
2097+ inferred_outlives
2098+ . iter ( )
2099+ . filter ( |( _, span) | !predicate. span . contains ( * span) ) ,
20982100 item. owner_id . to_def_id ( ) ,
20992101 region_def_id,
21002102 ) ,
@@ -2116,7 +2118,14 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
21162118 } ;
21172119 let index = ty_generics. param_def_id_to_index [ & def_id] ;
21182120 (
2119- Self :: lifetimes_outliving_type ( inferred_outlives, index) ,
2121+ Self :: lifetimes_outliving_type (
2122+ // don't warn if the inferred span actually came from the predicate we're looking at
2123+ // this happens if the type is recursively defined
2124+ inferred_outlives. iter ( ) . filter ( |( _, span) | {
2125+ !predicate. span . contains ( * span)
2126+ } ) ,
2127+ index,
2128+ ) ,
21202129 & predicate. bounds ,
21212130 predicate. span ,
21222131 predicate. origin == PredicateOrigin :: WhereClause ,
0 commit comments