Skip to content

Commit acc3bc1

Browse files
committed
result_map_or_into_option: move arg checks into tuple assignment
1 parent fb276dc commit acc3bc1

File tree

1 file changed

+13
-12
lines changed
  • clippy_lints/src/methods

1 file changed

+13
-12
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2559,26 +2559,27 @@ fn lint_map_or_none<'a, 'tcx>(
25592559
return;
25602560
}
25612561

2562-
let default_arg_is_none = if let hir::ExprKind::Path(ref qpath) = map_or_args[1].kind {
2563-
match_qpath(qpath, &paths::OPTION_NONE)
2564-
} else {
2565-
false
2566-
};
25672562

2568-
// This is really only needed if `is_result` holds. Computing it here
2569-
// makes `mess`'s assignment a bit easier, so just compute it here.
2570-
let f_arg_is_some = if let hir::ExprKind::Path(ref qpath) = map_or_args[2].kind {
2571-
match_qpath(qpath, &paths::OPTION_SOME)
2572-
} else {
2573-
false
2574-
};
25752563

25762564
let (lint, msg, instead, hint) = {
2565+
2566+
let default_arg_is_none = if let hir::ExprKind::Path(ref qpath) = map_or_args[1].kind {
2567+
match_qpath(qpath, &paths::OPTION_NONE)
2568+
} else {
2569+
return;
2570+
};
2571+
25772572
if !default_arg_is_none {
25782573
// nothing to lint!
25792574
return;
25802575
}
25812576

2577+
let f_arg_is_some = if let hir::ExprKind::Path(ref qpath) = map_or_args[2].kind {
2578+
match_qpath(qpath, &paths::OPTION_SOME)
2579+
} else {
2580+
false
2581+
};
2582+
25822583
if is_option {
25832584
let self_snippet = snippet(cx, map_or_args[0].span, "..");
25842585
let func_snippet = snippet(cx, map_or_args[2].span, "..");

0 commit comments

Comments
 (0)