From ce13ff15c33da1e31931ba4bc692709be3a2cf30 Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Sat, 15 Aug 2020 13:34:06 -0700 Subject: Correctly create artificial span for formatting closure body This commit partially reverts #3934, opting to create a span that covers the entire body of a closure when formatting a closure body with a block-formatting strategy, rather than having the block-formatting code determine if the visitor pointer should be rewound. The problem with rewinding the visitor pointer is it may be incorrect for other (i.e. non-artificial) AST nodes, as in the case of #4382. Closes #4382 --- src/expr.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/expr.rs') diff --git a/src/expr.rs b/src/expr.rs index 6bc54ff8601..1ba879ccc1d 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -528,17 +528,7 @@ pub(crate) fn rewrite_block_with_visitor( let open_pos = snippet.find_uncommented("{")?; visitor.last_pos = block.span.lo() + BytePos(open_pos as u32) } - (ast::BlockCheckMode::Default, None) => { - visitor.last_pos = block.span.lo(); - if let Some(attrs) = attrs { - if let Some(first) = attrs.first() { - let first_lo_span = first.span.lo(); - if first_lo_span < visitor.last_pos { - visitor.last_pos = first_lo_span; - } - } - } - } + (ast::BlockCheckMode::Default, None) => visitor.last_pos = block.span.lo(), } let inner_attrs = attrs.map(inner_attributes); -- cgit 1.4.1-3-g733a5