Skip to content

Commit a1fabbf

Browse files
Bugfix/comment duplication (rust-lang#5913)
* Fix rust-lang#5871 * Only idempotence test is necessary * Update src/expr.rs Co-authored-by: Caleb Cartwright <[email protected]> --------- Co-authored-by: Caleb Cartwright <[email protected]>
1 parent da7f678 commit a1fabbf

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ pub(crate) fn rewrite_paren(
14531453
let remove_nested_parens = context.config.remove_nested_parens();
14541454
loop {
14551455
// 1 = "(" or ")"
1456-
pre_span = mk_sp(span.lo() + BytePos(1), subexpr.span.lo());
1456+
pre_span = mk_sp(span.lo() + BytePos(1), subexpr.span().lo());
14571457
post_span = mk_sp(subexpr.span.hi(), span.hi() - BytePos(1));
14581458
pre_comment = rewrite_missing_comment(pre_span, shape, context)?;
14591459
post_comment = rewrite_missing_comment(post_span, shape, context)?;

tests/target/issue-5871.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(stmt_expr_attributes)]
2+
fn okay() -> u32 {
3+
(
4+
// Comments in parentheses-expressions caused attributes to be duplicated.
5+
#[allow(unused_variables)]
6+
0
7+
)
8+
}

0 commit comments

Comments
 (0)