We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 79509be + 3801d21 commit cdd1347Copy full SHA for cdd1347
clippy_lints/src/utils/mod.rs
@@ -873,12 +873,11 @@ pub fn is_automatically_derived(attrs: &[ast::Attribute]) -> bool {
873
///
874
/// Ie. `x`, `{ x }` and `{{{{ x }}}}` all give `x`. `{ x; y }` and `{}` return
875
/// themselves.
876
-pub fn remove_blocks<'tcx>(expr: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> {
877
- if let ExprKind::Block(ref block, _) = expr.kind {
878
- if block.stmts.is_empty() {
879
- if let Some(ref expr) = block.expr {
880
- return remove_blocks(expr);
881
- }
+pub fn remove_blocks<'tcx>(mut expr: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> {
+ while let ExprKind::Block(ref block, ..) = expr.kind {
+ match (block.stmts.is_empty(), block.expr.as_ref()) {
+ (true, Some(e)) => expr = e,
+ _ => break,
882
}
883
884
expr
0 commit comments