Dogfood inside if_let_chain!

This commit is contained in:
mcarton 2016-06-06 18:55:22 +02:00
parent 489576437d
commit dd99a88289
No known key found for this signature in database
GPG Key ID: 5E427C794CBA45E8
2 changed files with 7 additions and 9 deletions

View File

@ -339,15 +339,15 @@ fn all_ranges(cx: &LateContext, arms: &[Arm]) -> Vec<SpannedRange<ConstVal>> {
Some(pats.iter().filter_map(|pat| {
if_let_chain! {[
let PatKind::Range(ref lhs, ref rhs) = pat.node,
let Ok(lhs) = eval_const_expr_partial(cx.tcx, &lhs, ExprTypeChecked, None),
let Ok(rhs) = eval_const_expr_partial(cx.tcx, &rhs, ExprTypeChecked, None)
let Ok(lhs) = eval_const_expr_partial(cx.tcx, lhs, ExprTypeChecked, None),
let Ok(rhs) = eval_const_expr_partial(cx.tcx, rhs, ExprTypeChecked, None)
], {
return Some(SpannedRange { span: pat.span, node: (lhs, rhs) });
}}
if_let_chain! {[
let PatKind::Lit(ref value) = pat.node,
let Ok(value) = eval_const_expr_partial(cx.tcx, &value, ExprTypeChecked, None)
let Ok(value) = eval_const_expr_partial(cx.tcx, value, ExprTypeChecked, None)
], {
return Some(SpannedRange { span: pat.span, node: (value.clone(), value) });
}}

View File

@ -104,13 +104,11 @@ impl LateLintPass for RegexPass {
let Some(def) = cx.tcx.def_map.borrow().get(&fun.id),
], {
let def_id = def.def_id();
if match_def_path(cx, def_id, &paths::REGEX_NEW) {
if match_def_path(cx, def_id, &paths::REGEX_NEW) ||
match_def_path(cx, def_id, &paths::REGEX_BUILDER_NEW) {
check_regex(cx, &args[0], true);
} else if match_def_path(cx, def_id, &paths::REGEX_BYTES_NEW) {
check_regex(cx, &args[0], false);
} else if match_def_path(cx, def_id, &paths::REGEX_BUILDER_NEW) {
check_regex(cx, &args[0], true);
} else if match_def_path(cx, def_id, &paths::REGEX_BYTES_BUILDER_NEW) {
} else if match_def_path(cx, def_id, &paths::REGEX_BYTES_NEW) ||
match_def_path(cx, def_id, &paths::REGEX_BYTES_BUILDER_NEW) {
check_regex(cx, &args[0], false);
} else if match_def_path(cx, def_id, &paths::REGEX_SET_NEW) {
check_set(cx, &args[0], true);