Skip to content

Commit 5d5960d

Browse files
author
Alexander Glusker
committed
2st review on issue-6116 solvation
1 parent c60a4d9 commit 5d5960d

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/closures.rs

Lines changed: 7 additions & 8 deletions
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;
@@ -108,10 +107,7 @@ fn get_inner_expr<'a>(
108107
if !needs_block(block, prefix, context) {
109108
// block.stmts.len() == 1 except with `|| {{}}`;
110109
// https://github.com/rust-lang/rustfmt/issues/3844
111-
if let Some(expr) = iter_stmts_without_empty(&block.stmts)
112-
.next()
113-
.and_then(stmt_expr)
114-
{
110+
if let Some(expr) = iter_stmts_without_empty(&block).next().and_then(stmt_expr) {
115111
return get_inner_expr(expr, prefix, context);
116112
}
117113
}
@@ -120,8 +116,11 @@ fn get_inner_expr<'a>(
120116
expr
121117
}
122118

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

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

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

0 commit comments

Comments
 (0)