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