]> git.lizzy.rs Git - rust.git/commitdiff
needless-lifetime / multiple where clause predicates regression
authorTim Nielens <tim.nielens@gmail.com>
Mon, 19 Oct 2020 22:38:13 +0000 (00:38 +0200)
committerTim Nielens <tim.nielens@gmail.com>
Mon, 19 Oct 2020 22:42:00 +0000 (00:42 +0200)
clippy_lints/src/lifetimes.rs
tests/ui/needless_lifetimes.rs

index d7043e7bd8f713ce010fc84c48ef2f70fb48ace2..c8a5a9c9431352ab2d2f4f7cf09c07fa55677550 100644 (file)
@@ -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);
index d482d466e44990df8f0fdcb19d4d4f6fbafc0bbf..6001ef37eb781cbb497397e1cbbdb74fd0d7bcb6 100644 (file)
@@ -357,4 +357,15 @@ fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) {
     }
 }
 
+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() {}