@@ -2124,12 +2124,16 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
2124
2124
}
2125
2125
2126
2126
let ty_generics = cx. tcx . generics_of ( def_id) ;
2127
+ let num_where_predicates = hir_generics
2128
+ . predicates
2129
+ . iter ( )
2130
+ . filter ( |predicate| predicate. in_where_clause ( ) )
2131
+ . count ( ) ;
2127
2132
2128
2133
let mut bound_count = 0 ;
2129
2134
let mut lint_spans = Vec :: new ( ) ;
2130
2135
let mut where_lint_spans = Vec :: new ( ) ;
2131
- let mut dropped_predicate_count = 0 ;
2132
- let num_predicates = hir_generics. predicates . len ( ) ;
2136
+ let mut dropped_where_predicate_count = 0 ;
2133
2137
for ( i, where_predicate) in hir_generics. predicates . iter ( ) . enumerate ( ) {
2134
2138
let ( relevant_lifetimes, bounds, predicate_span, in_where_clause) =
2135
2139
match where_predicate {
@@ -2186,8 +2190,8 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
2186
2190
bound_count += bound_spans. len ( ) ;
2187
2191
2188
2192
let drop_predicate = bound_spans. len ( ) == bounds. len ( ) ;
2189
- if drop_predicate {
2190
- dropped_predicate_count += 1 ;
2193
+ if drop_predicate && in_where_clause {
2194
+ dropped_where_predicate_count += 1 ;
2191
2195
}
2192
2196
2193
2197
if drop_predicate {
@@ -2196,7 +2200,7 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
2196
2200
} else if predicate_span. from_expansion ( ) {
2197
2201
// Don't try to extend the span if it comes from a macro expansion.
2198
2202
where_lint_spans. push ( predicate_span) ;
2199
- } else if i + 1 < num_predicates {
2203
+ } else if i + 1 < num_where_predicates {
2200
2204
// If all the bounds on a predicate were inferable and there are
2201
2205
// further predicates, we want to eat the trailing comma.
2202
2206
let next_predicate_span = hir_generics. predicates [ i + 1 ] . span ( ) ;
@@ -2224,9 +2228,10 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitOutlivesRequirements {
2224
2228
}
2225
2229
}
2226
2230
2227
- // If all predicates are inferable, drop the entire clause
2231
+ // If all predicates in where clause are inferable, drop the entire clause
2228
2232
// (including the `where`)
2229
- if hir_generics. has_where_clause_predicates && dropped_predicate_count == num_predicates
2233
+ if hir_generics. has_where_clause_predicates
2234
+ && dropped_where_predicate_count == num_where_predicates
2230
2235
{
2231
2236
let where_span = hir_generics. where_clause_span ;
2232
2237
// Extend the where clause back to the closing `>` of the
0 commit comments