about summary refs log tree commit diff
diff options
context:
space:
mode:
authorinfrandomness <infrandomness@gmail.com>2022-04-10 10:59:43 +0200
committerinfrandomness <infrandomness@gmail.com>2022-04-14 13:16:20 +0200
commitb52bc9b96bb3b22b4ab4a793e3706e7a9b718952 (patch)
treefcc6ff1863a5c9f65fc705251ca7dd9dd2d73897
parent8b2b343b23c50e136e14c303f2579ae2a2fda5f2 (diff)
Swap type checked expression
Instead of type checking the entire expression (causing a false
positive), only type check for a subset of the expression (the receiver of
the matched function: `take()`)
-rw-r--r--clippy_lints/src/methods/needless_option_take.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/clippy_lints/src/methods/needless_option_take.rs b/clippy_lints/src/methods/needless_option_take.rs
index 57a43ff606a..297d83e9e37 100644
--- a/clippy_lints/src/methods/needless_option_take.rs
+++ b/clippy_lints/src/methods/needless_option_take.rs
@@ -10,7 +10,7 @@ use super::NEEDLESS_OPTION_TAKE;
 
 pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, recv: &'tcx Expr<'_>) {
     // Checks if expression type is equal to sym::Option and if the expr is not a syntactic place
-    if is_expr_option(cx, expr) && !expr.is_syntactic_place_expr() {
+    if is_expr_option(cx, recv) && !recv.is_syntactic_place_expr() {
         let mut applicability = Applicability::MachineApplicable;
         span_lint_and_sugg(
             cx,