Skip to content

Commit 116f30d

Browse files
committed
Use else blocks instead of return statements in Increment/InitializeVisitor
1 parent dc89bb1 commit 116f30d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

clippy_lints/src/loops.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,16 +2181,17 @@ impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> {
21812181
_ => (),
21822182
}
21832183
}
2184+
2185+
walk_expr(self, expr);
21842186
} else if is_loop(expr) || is_conditional(expr) {
21852187
self.depth += 1;
21862188
walk_expr(self, expr);
21872189
self.depth -= 1;
2188-
return;
21892190
} else if let ExprKind::Continue(_) = expr.kind {
21902191
self.done = true;
2191-
return;
2192+
} else {
2193+
walk_expr(self, expr);
21922194
}
2193-
walk_expr(self, expr);
21942195
}
21952196
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
21962197
NestedVisitorMap::None
@@ -2272,16 +2273,16 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
22722273
self.state = VarState::DontWarn;
22732274
return;
22742275
}
2276+
walk_expr(self, expr);
22752277
} else if !self.past_loop && is_loop(expr) {
22762278
self.state = VarState::DontWarn;
2277-
return;
22782279
} else if is_conditional(expr) {
22792280
self.depth += 1;
22802281
walk_expr(self, expr);
22812282
self.depth -= 1;
2282-
return;
2283+
} else {
2284+
walk_expr(self, expr);
22832285
}
2284-
walk_expr(self, expr);
22852286
}
22862287

22872288
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {

0 commit comments

Comments
 (0)