about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-10-25 11:15:01 +0000
committerbors <bors@rust-lang.org>2020-10-25 11:15:01 +0000
commit38be214724f44ce4ff5944068cb1be3a79b0d218 (patch)
tree8b46ee99808759d6f870a1dd618c8b0a0d3d3ead
parent90cb25d3f687a2b888174e604f48d6807a6d036c (diff)
parent65b52d84f83586752bff2834410e131290dc0155 (diff)
downloadrust-38be214724f44ce4ff5944068cb1be3a79b0d218.tar.gz
rust-38be214724f44ce4ff5944068cb1be3a79b0d218.zip
Auto merge of #6198 - montrivo:needless-lifetime, r=flip1995
needless-lifetime / multiple where clause predicates regression

Closes #6159.

changelog: fix regression in needless-lifetimes
-rw-r--r--clippy_lints/src/lifetimes.rs6
-rw-r--r--tests/ui/needless_lifetimes.rs11
2 files changed, 15 insertions, 2 deletions
diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs
index d7043e7bd8f..c8a5a9c9431 100644
--- a/clippy_lints/src/lifetimes.rs
+++ b/clippy_lints/src/lifetimes.rs
@@ -414,7 +414,7 @@ fn has_where_lifetimes<'tcx>(cx: &LateContext<'tcx>, where_clause: &'tcx WhereCl
                 let mut visitor = RefVisitor::new(cx);
                 // walk the type F, it may not contain LT refs
                 walk_ty(&mut visitor, &pred.bounded_ty);
-                if !visitor.lts.is_empty() {
+                if !visitor.all_lts().is_empty() {
                     return true;
                 }
                 // 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
                     walk_param_bound(&mut visitor, bound);
                 }
                 // and check that all lifetimes are allowed
-                return visitor.all_lts().iter().any(|it| !allowed_lts.contains(it));
+                if visitor.all_lts().iter().any(|it| !allowed_lts.contains(it)) {
+                    return true;
+                }
             },
             WherePredicate::EqPredicate(ref pred) => {
                 let mut visitor = RefVisitor::new(cx);
diff --git a/tests/ui/needless_lifetimes.rs b/tests/ui/needless_lifetimes.rs
index d482d466e44..6001ef37eb7 100644
--- a/tests/ui/needless_lifetimes.rs
+++ b/tests/ui/needless_lifetimes.rs
@@ -357,4 +357,15 @@ mod nested_elision_sites {
     }
 }
 
+mod issue6159 {
+    use std::ops::Deref;
+    pub fn apply_deref<'a, T, F, R>(x: &'a T, f: F) -> R
+    where
+        T: Deref,
+        F: FnOnce(&'a T::Target) -> R,
+    {
+        f(x.deref())
+    }
+}
+
 fn main() {}