@@ -1924,14 +1924,13 @@ declare_lint_pass!(ExplicitOutlivesRequirements => [EXPLICIT_OUTLIVES_REQUIREMEN
1924
1924
impl ExplicitOutlivesRequirements {
1925
1925
fn lifetimes_outliving_lifetime < ' tcx > (
1926
1926
tcx : TyCtxt < ' tcx > ,
1927
- inferred_outlives : & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] ,
1927
+ inferred_outlives : impl Iterator < Item = & ' tcx ( ty:: Clause < ' tcx > , Span ) > ,
1928
1928
item : DefId ,
1929
1929
lifetime : DefId ,
1930
1930
) -> Vec < ty:: Region < ' tcx > > {
1931
1931
let item_generics = tcx. generics_of ( item) ;
1932
1932
1933
1933
inferred_outlives
1934
- . iter ( )
1935
1934
. filter_map ( |( clause, _) | match clause. kind ( ) . skip_binder ( ) {
1936
1935
ty:: ClauseKind :: RegionOutlives ( ty:: OutlivesPredicate ( a, b) ) => match * a {
1937
1936
ty:: ReEarlyParam ( ebr)
@@ -1947,11 +1946,10 @@ impl ExplicitOutlivesRequirements {
1947
1946
}
1948
1947
1949
1948
fn lifetimes_outliving_type < ' tcx > (
1950
- inferred_outlives : & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] ,
1949
+ inferred_outlives : impl Iterator < Item = & ' tcx ( ty:: Clause < ' tcx > , Span ) > ,
1951
1950
index : u32 ,
1952
1951
) -> Vec < ty:: Region < ' tcx > > {
1953
1952
inferred_outlives
1954
- . iter ( )
1955
1953
. filter_map ( |( clause, _) | match clause. kind ( ) . skip_binder ( ) {
1956
1954
ty:: ClauseKind :: TypeOutlives ( ty:: OutlivesPredicate ( a, b) ) => {
1957
1955
a. is_param ( index) . then_some ( b)
@@ -2094,7 +2092,11 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
2094
2092
(
2095
2093
Self :: lifetimes_outliving_lifetime (
2096
2094
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) ) ,
2098
2100
item. owner_id . to_def_id ( ) ,
2099
2101
region_def_id,
2100
2102
) ,
@@ -2116,7 +2118,14 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
2116
2118
} ;
2117
2119
let index = ty_generics. param_def_id_to_index [ & def_id] ;
2118
2120
(
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
+ ) ,
2120
2129
& predicate. bounds ,
2121
2130
predicate. span ,
2122
2131
predicate. origin == PredicateOrigin :: WhereClause ,
0 commit comments