@@ -180,11 +180,12 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
180
180
}
181
181
}
182
182
183
- /// Remove spaces between the opening brace and the first statement or the inner attribute
184
- /// of the block, fast-forwarding this position of the visitor.
183
+ /// Advances the position of the visitor to the first statement or the inner attribute of a
184
+ /// block.
185
+ ///
185
186
/// If `preserve_block_start_blank_lines` is true, the return value contains the newlines that
186
187
/// should be preserved.
187
- pub ( crate ) fn trim_spaces_after_opening_brace (
188
+ pub ( crate ) fn advance_to_first_block_item (
188
189
& mut self ,
189
190
first_item_pos : Option < BytePos > ,
190
191
) -> String {
@@ -266,9 +267,9 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
266
267
self . push_str ( "{" ) ;
267
268
268
269
let first_non_ws = inner_attrs
269
- . and_then ( |attrs| inner_attributes ( attrs) . first ( ) . map ( |attr| attr. span . lo ( ) ) )
270
- . or ( b. stmts . first ( ) . map ( |s| s. span ( ) . lo ( ) ) ) ;
271
- let opening_nls = & self . trim_spaces_after_opening_brace ( first_non_ws) ;
270
+ . and_then ( |attrs| attrs. first ( ) . map ( |attr| attr. span . lo ( ) ) )
271
+ . or_else ( || b. stmts . first ( ) . map ( |s| s. span ( ) . lo ( ) ) ) ;
272
+ let opening_nls = & self . advance_to_first_block_item ( first_non_ws) ;
272
273
self . push_str ( & opening_nls) ;
273
274
274
275
// Format inner attributes if available.
@@ -993,8 +994,8 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
993
994
let first_non_ws = inner_attributes ( attrs)
994
995
. first ( )
995
996
. map ( |attr| attr. span . lo ( ) )
996
- . or ( m. items . first ( ) . map ( |s| s. span ( ) . lo ( ) ) ) ;
997
- let opening_nls = & self . trim_spaces_after_opening_brace ( first_non_ws) ;
997
+ . or_else ( || m. items . first ( ) . map ( |s| s. span ( ) . lo ( ) ) ) ;
998
+ let opening_nls = & self . advance_to_first_block_item ( first_non_ws) ;
998
999
self . push_str ( & opening_nls) ;
999
1000
1000
1001
self . visit_attrs ( attrs, ast:: AttrStyle :: Inner ) ;
0 commit comments