Skip to content

Commit b52bc9b

Browse files
committed
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()`)
1 parent 8b2b343 commit b52bc9b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clippy_lints/src/methods/needless_option_take.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::NEEDLESS_OPTION_TAKE;
1010

1111
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, recv: &'tcx Expr<'_>) {
1212
// Checks if expression type is equal to sym::Option and if the expr is not a syntactic place
13-
if is_expr_option(cx, expr) && !expr.is_syntactic_place_expr() {
13+
if is_expr_option(cx, recv) && !recv.is_syntactic_place_expr() {
1414
let mut applicability = Applicability::MachineApplicable;
1515
span_lint_and_sugg(
1616
cx,

0 commit comments

Comments
 (0)