mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 03:03:40 +00:00
Dogfood inside if_let_chain!
This commit is contained in:
parent
489576437d
commit
dd99a88289
@ -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) });
|
||||
}}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user