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:
parent
da7f67810f
commit
a1fabbf386
@ -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)?;
|
||||
|
8
tests/target/issue-5871.rs
Normal file
8
tests/target/issue-5871.rs
Normal 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
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue
Block a user