1- use rustc_ast:: ast:: StmtKind ;
21use rustc_ast:: { ast, ptr} ;
32use rustc_span:: Span ;
43use 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