1
- use rustc_ast:: ast:: StmtKind ;
2
1
use rustc_ast:: { ast, ptr} ;
3
2
use rustc_span:: Span ;
4
3
use thin_vec:: thin_vec;
@@ -108,10 +107,7 @@ fn get_inner_expr<'a>(
108
107
if !needs_block ( block, prefix, context) {
109
108
// block.stmts.len() == 1 except with `|| {{}}`;
110
109
// 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) {
115
111
return get_inner_expr ( expr, prefix, context) ;
116
112
}
117
113
}
@@ -120,8 +116,11 @@ fn get_inner_expr<'a>(
120
116
expr
121
117
}
122
118
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 ) )
125
124
}
126
125
127
126
// Figure out if a block is necessary.
@@ -131,7 +130,7 @@ fn needs_block(block: &ast::Block, prefix: &str, context: &RewriteContext<'_>) -
131
130
} ) ;
132
131
133
132
is_unsafe_block ( block)
134
- || iter_stmts_without_empty ( & block. stmts ) . count ( ) > 1
133
+ || iter_stmts_without_empty ( & block) . count ( ) > 1
135
134
|| has_attributes
136
135
|| block_contains_comment ( context, block)
137
136
|| prefix. contains ( '\n' )
0 commit comments