Skip to content

Commit 38be214

Browse files
committed
Auto merge of rust-lang#6198 - montrivo:needless-lifetime, r=flip1995
needless-lifetime / multiple where clause predicates regression Closes rust-lang#6159. changelog: fix regression in needless-lifetimes
2 parents 90cb25d + 65b52d8 commit 38be214

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

clippy_lints/src/lifetimes.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ fn has_where_lifetimes<'tcx>(cx: &LateContext<'tcx>, where_clause: &'tcx WhereCl
414414
let mut visitor = RefVisitor::new(cx);
415415
// walk the type F, it may not contain LT refs
416416
walk_ty(&mut visitor, &pred.bounded_ty);
417-
if !visitor.lts.is_empty() {
417+
if !visitor.all_lts().is_empty() {
418418
return true;
419419
}
420420
// if the bounds define new lifetimes, they are fine to occur
@@ -424,7 +424,9 @@ fn has_where_lifetimes<'tcx>(cx: &LateContext<'tcx>, where_clause: &'tcx WhereCl
424424
walk_param_bound(&mut visitor, bound);
425425
}
426426
// and check that all lifetimes are allowed
427-
return visitor.all_lts().iter().any(|it| !allowed_lts.contains(it));
427+
if visitor.all_lts().iter().any(|it| !allowed_lts.contains(it)) {
428+
return true;
429+
}
428430
},
429431
WherePredicate::EqPredicate(ref pred) => {
430432
let mut visitor = RefVisitor::new(cx);

tests/ui/needless_lifetimes.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,15 @@ mod nested_elision_sites {
357357
}
358358
}
359359

360+
mod issue6159 {
361+
use std::ops::Deref;
362+
pub fn apply_deref<'a, T, F, R>(x: &'a T, f: F) -> R
363+
where
364+
T: Deref,
365+
F: FnOnce(&'a T::Target) -> R,
366+
{
367+
f(x.deref())
368+
}
369+
}
370+
360371
fn main() {}

0 commit comments

Comments
 (0)