Skip to content

Commit 4f817e0

Browse files
Alexander Gluskerytmimi
Alexander Glusker
authored andcommitted
2st review on issue-6116 solvation
1 parent d40e289 commit 4f817e0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/closures.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use rustc_ast::ast::StmtKind;
21
use rustc_ast::{ast, ptr};
32
use rustc_span::Span;
43
use thin_vec::thin_vec;
@@ -109,10 +108,7 @@ fn get_inner_expr<'a>(
109108
if !needs_block(block, prefix, context) {
110109
// block.stmts.len() == 1 except with `|| {{}}`;
111110
// https://github.com/rust-lang/rustfmt/issues/3844
112-
if let Some(expr) = iter_stmts_without_empty(&block.stmts)
113-
.next()
114-
.and_then(stmt_expr)
115-
{
111+
if let Some(expr) = iter_stmts_without_empty(&block).next().and_then(stmt_expr) {
116112
return get_inner_expr(expr, prefix, context);
117113
}
118114
}
@@ -121,8 +117,11 @@ fn get_inner_expr<'a>(
121117
expr
122118
}
123119

124-
fn iter_stmts_without_empty(stmts: &[ast::Stmt]) -> impl Iterator<Item = &ast::Stmt> {
125-
stmts.iter().filter(|x| !matches!(x.kind, StmtKind::Empty))
120+
fn iter_stmts_without_empty(block: &ast::Block) -> impl Iterator<Item = &ast::Stmt> {
121+
block
122+
.stmts
123+
.iter()
124+
.filter(|stmt| !matches!(stmt.kind, ast::StmtKind::Empty))
126125
}
127126

128127
// Figure out if a block is necessary.
@@ -132,7 +131,7 @@ fn needs_block(block: &ast::Block, prefix: &str, context: &RewriteContext<'_>) -
132131
});
133132

134133
is_unsafe_block(block)
135-
|| iter_stmts_without_empty(&block.stmts).count() > 1
134+
|| iter_stmts_without_empty(&block).count() > 1
136135
|| has_attributes
137136
|| block_contains_comment(context, block)
138137
|| prefix.contains('\n')

0 commit comments

Comments
 (0)