result_map_or_into_option: move arg checks into tuple assignment

This commit is contained in:
Nick Torres 2020-04-04 14:24:22 -07:00
parent fb276dc3fa
commit acc3bc1ba2

View File

@ -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, "..");