- if self.config.remove_blank_lines_at_start_or_end_of_block() {
- if let Some(first_stmt) = b.stmts.first() {
- let attr_lo = inner_attrs
- .and_then(|attrs| inner_attributes(attrs).first().map(|attr| attr.span.lo()))
- .or_else(|| {
- // Attributes for an item in a statement position
- // do not belong to the statement. (rust-lang/rust#34459)
- if let ast::StmtKind::Item(ref item) = first_stmt.node {
- item.attrs.first()
- } else {
- first_stmt.attrs().first()
- }.and_then(|attr| {
- // Some stmts can have embedded attributes.
- // e.g. `match { #![attr] ... }`
- let attr_lo = attr.span.lo();
- if attr_lo < first_stmt.span.lo() {
- Some(attr_lo)
- } else {
- None
- }
- })
- });
-
- let snippet = self.snippet(mk_sp(
- self.last_pos,
- attr_lo.unwrap_or_else(|| first_stmt.span.lo()),
- ));
- let len = CommentCodeSlices::new(snippet)
- .nth(0)
- .and_then(|(kind, _, s)| {
- if kind == CodeCharKind::Normal {
- s.rfind('\n')
+ if let Some(first_stmt) = b.stmts.first() {
+ let attr_lo = inner_attrs
+ .and_then(|attrs| inner_attributes(attrs).first().map(|attr| attr.span.lo()))
+ .or_else(|| {
+ // Attributes for an item in a statement position
+ // do not belong to the statement. (rust-lang/rust#34459)
+ if let ast::StmtKind::Item(ref item) = first_stmt.node {
+ item.attrs.first()
+ } else {
+ first_stmt.attrs().first()
+ }
+ .and_then(|attr| {
+ // Some stmts can have embedded attributes.
+ // e.g. `match { #![attr] ... }`
+ let attr_lo = attr.span.lo();
+ if attr_lo < first_stmt.span.lo() {
+ Some(attr_lo)