Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
chore: code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Sep 27, 2022
1 parent 6a0c0cf commit d57be36
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,18 @@ impl Rule for UseBlockStatements {

r_curly_token.with_leading_trivia(leading_trivia)
} else {
let has_trailing_comments = stmt.syntax().has_trailing_comments();
// if the node we have to enclose has some leading comments, then we add a new line
let has_trailing_single_line_comments = stmt
.syntax()
.last_trailing_trivia()
.map(|trivia| {
trivia
.pieces()
.any(|trivia| trivia.kind() == TriviaPieceKind::SingleLineComment)
})
.unwrap_or(false);
// if the node we have to enclose has some trailing comments, then we add a new line
// to the leading trivia of the right curly brace
if !has_trailing_comments {
if !has_trailing_single_line_comments {
r_curly_token
.with_leading_trivia(iter::once((TriviaPieceKind::Whitespace, " ")))
} else {
Expand Down

0 comments on commit d57be36

Please sign in to comment.