Skip to content

Commit af9e59d

Browse files
committed
Remove some unnecessary If arms
1 parent 206eb79 commit af9e59d

File tree

7 files changed

+1
-42
lines changed

7 files changed

+1
-42
lines changed

clippy_lints/src/implicit_return.rs

-7
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ impl ImplicitReturn {
7474
Self::lint(cx, expr.span, break_expr.span, "change `break` to `return` as shown");
7575
}
7676
},
77-
ExprKind::If(.., if_expr, else_expr) => {
78-
Self::expr_match(cx, if_expr);
79-
80-
if let Some(else_expr) = else_expr {
81-
Self::expr_match(cx, else_expr);
82-
}
83-
},
8477
ExprKind::Match(.., arms, source) => {
8578
let check_all_arms = match source {
8679
MatchSource::IfLetDesugar {

clippy_lints/src/loops.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -686,14 +686,6 @@ fn never_loop_expr(expr: &Expr, main_loop_id: HirId) -> NeverLoopResult {
686686
| ExprKind::Assign(ref e1, ref e2)
687687
| ExprKind::AssignOp(_, ref e1, ref e2)
688688
| ExprKind::Index(ref e1, ref e2) => never_loop_expr_all(&mut [&**e1, &**e2].iter().cloned(), main_loop_id),
689-
ExprKind::If(ref e, ref e2, ref e3) => {
690-
let e1 = never_loop_expr(e, main_loop_id);
691-
let e2 = never_loop_expr(e2, main_loop_id);
692-
let e3 = e3
693-
.as_ref()
694-
.map_or(NeverLoopResult::Otherwise, |e| never_loop_expr(e, main_loop_id));
695-
combine_seq(e1, combine_branches(e2, e3))
696-
},
697689
ExprKind::Loop(ref b, _, _) => {
698690
// Break can come from the inner loop so remove them.
699691
absorb_break(&never_loop_block(b, main_loop_id))
@@ -2204,7 +2196,7 @@ fn is_loop(expr: &Expr) -> bool {
22042196

22052197
fn is_conditional(expr: &Expr) -> bool {
22062198
match expr.node {
2207-
ExprKind::If(..) | ExprKind::Match(..) => true,
2199+
ExprKind::Match(..) => true,
22082200
_ => false,
22092201
}
22102202
}

clippy_lints/src/methods/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,6 @@ fn lint_expect_fun_call(cx: &LateContext<'_, '_>, expr: &hir::Expr, method_span:
12661266
hir::ExprKind::Call(..)
12671267
| hir::ExprKind::MethodCall(..)
12681268
// These variants are debatable or require further examination
1269-
| hir::ExprKind::If(..)
12701269
| hir::ExprKind::Match(..)
12711270
| hir::ExprKind::Block{ .. } => true,
12721271
_ => false,

clippy_lints/src/methods/unnecessary_filter_map.rs

-6
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ fn check_expression<'a, 'tcx: 'a>(
8989
(false, false)
9090
}
9191
},
92-
// There must be an else_arm or there will be a type error
93-
hir::ExprKind::If(_, ref if_arm, Some(ref else_arm)) => {
94-
let if_check = check_expression(cx, arg_id, if_arm);
95-
let else_check = check_expression(cx, arg_id, else_arm);
96-
(if_check.0 | else_check.0, if_check.1 | else_check.1)
97-
},
9892
hir::ExprKind::Match(_, ref arms, _) => {
9993
let mut found_mapping = false;
10094
let mut found_filtering = false;

clippy_lints/src/utils/hir_utils.rs

-9
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,6 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
493493
let c: fn(_, _, _) -> _ = ExprKind::InlineAsm;
494494
c.hash(&mut self.s);
495495
},
496-
ExprKind::If(ref cond, ref t, ref e) => {
497-
let c: fn(_, _, _) -> _ = ExprKind::If;
498-
c.hash(&mut self.s);
499-
self.hash_expr(cond);
500-
self.hash_expr(&**t);
501-
if let Some(ref e) = *e {
502-
self.hash_expr(e);
503-
}
504-
},
505496
ExprKind::Lit(ref l) => {
506497
let c: fn(_) -> _ = ExprKind::Lit;
507498
c.hash(&mut self.s);

clippy_lints/src/utils/inspector.rs

-9
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,6 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
209209
print_expr(cx, e, indent + 1);
210210
println!("{}target type: {:?}", ind, target);
211211
},
212-
hir::ExprKind::If(ref e, _, ref els) => {
213-
println!("{}If", ind);
214-
println!("{}condition:", ind);
215-
print_expr(cx, e, indent + 1);
216-
if let Some(ref els) = *els {
217-
println!("{}else:", ind);
218-
print_expr(cx, els, indent + 1);
219-
}
220-
},
221212
hir::ExprKind::While(ref cond, _, _) => {
222213
println!("{}While", ind);
223214
println!("{}condition:", ind);

clippy_lints/src/utils/sugg.rs

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ impl<'a> Sugg<'a> {
9494
hir::ExprKind::AddrOf(..)
9595
| hir::ExprKind::Box(..)
9696
| hir::ExprKind::Closure(.., _)
97-
| hir::ExprKind::If(..)
9897
| hir::ExprKind::Unary(..)
9998
| hir::ExprKind::Match(..) => Sugg::MaybeParen(snippet),
10099
hir::ExprKind::Continue(..)

0 commit comments

Comments
 (0)