Bugfix/comment duplication (#5913)

* Fix #5871

* Only idempotence test is necessary

* Update src/expr.rs

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>

---------

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
This commit is contained in:
GambitingMan 2023-09-20 21:29:02 +02:00 committed by GitHub
parent da7f67810f
commit a1fabbf386
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -1453,7 +1453,7 @@ pub(crate) fn rewrite_paren(
let remove_nested_parens = context.config.remove_nested_parens();
loop {
// 1 = "(" or ")"
pre_span = mk_sp(span.lo() + BytePos(1), subexpr.span.lo());
pre_span = mk_sp(span.lo() + BytePos(1), subexpr.span().lo());
post_span = mk_sp(subexpr.span.hi(), span.hi() - BytePos(1));
pre_comment = rewrite_missing_comment(pre_span, shape, context)?;
post_comment = rewrite_missing_comment(post_span, shape, context)?;

View File

@ -0,0 +1,8 @@
#![feature(stmt_expr_attributes)]
fn okay() -> u32 {
(
// Comments in parentheses-expressions caused attributes to be duplicated.
#[allow(unused_variables)]
0
)
}