diff options
| author | Nick Torres <nickrtorres@icloud.com> | 2020-04-04 14:24:22 -0700 |
|---|---|---|
| committer | Nick Torres <nickrtorres@icloud.com> | 2020-04-04 14:24:22 -0700 |
| commit | acc3bc1ba27129f6fc5bda6d943046e9e2ad2d45 (patch) | |
| tree | 17cb86d64b92d9b9968bda10634f9fe5c85dd542 | |
| parent | fb276dc3fa1d644ce6de1849ff3b78d3e54f5d9e (diff) | |
| download | rust-acc3bc1ba27129f6fc5bda6d943046e9e2ad2d45.tar.gz rust-acc3bc1ba27129f6fc5bda6d943046e9e2ad2d45.zip | |
result_map_or_into_option: move arg checks into tuple assignment
| -rw-r--r-- | clippy_lints/src/methods/mod.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 62fcd801bc3..d57cce47ff9 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -2559,26 +2559,27 @@ fn lint_map_or_none<'a, 'tcx>( return; } - let default_arg_is_none = if let hir::ExprKind::Path(ref qpath) = map_or_args[1].kind { - match_qpath(qpath, &paths::OPTION_NONE) - } else { - false - }; - // This is really only needed if `is_result` holds. Computing it here - // makes `mess`'s assignment a bit easier, so just compute it here. - let f_arg_is_some = if let hir::ExprKind::Path(ref qpath) = map_or_args[2].kind { - match_qpath(qpath, &paths::OPTION_SOME) - } else { - false - }; let (lint, msg, instead, hint) = { + + let default_arg_is_none = if let hir::ExprKind::Path(ref qpath) = map_or_args[1].kind { + match_qpath(qpath, &paths::OPTION_NONE) + } else { + return; + }; + if !default_arg_is_none { // nothing to lint! return; } + let f_arg_is_some = if let hir::ExprKind::Path(ref qpath) = map_or_args[2].kind { + match_qpath(qpath, &paths::OPTION_SOME) + } else { + false + }; + if is_option { let self_snippet = snippet(cx, map_or_args[0].span, ".."); let func_snippet = snippet(cx, map_or_args[2].span, ".."); |
