From b52bc9b96bb3b22b4ab4a793e3706e7a9b718952 Mon Sep 17 00:00:00 2001 From: infrandomness Date: Sun, 10 Apr 2022 10:59:43 +0200 Subject: [PATCH] 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()`) --- clippy_lints/src/methods/needless_option_take.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/methods/needless_option_take.rs b/clippy_lints/src/methods/needless_option_take.rs index 57a43ff606a5..297d83e9e37d 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,