]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/methods/search_is_some.rs
Correct suggestion when dereferencing enough, calling a function
[rust.git] / clippy_lints / src / methods / search_is_some.rs
index dca4d84f6b1ff405986028a8d22c4fc6f9d083be..98ad7f3866fd5d40a1f1de36711663fc7afda194 100644 (file)
@@ -248,7 +248,6 @@ fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {
                         let expr = self.cx.tcx.hir().expect_expr(cmt.hir_id);
                         let arg_ty_kind = self.cx.typeck_results().expr_ty(expr).kind();
 
-                        // Note: this should always be true, as `find` only gives us a reference which are not mutable
                         if matches!(arg_ty_kind, ty::Ref(_, _, Mutability::Not)) {
                             let start_span = Span::new(self.next_pos, span.lo(), span.ctxt());
                             let start_snip =
@@ -261,10 +260,10 @@ fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {
                             };
                             self.suggestion_start.push_str(&ident_sugg);
                             self.next_pos = span.hi();
+                            return;
                         } else {
                             self.applicability = Applicability::Unspecified;
                         }
-                        return;
                     }
                 }