Newlines are (inconsistently) removed around lines with only semicolons
Open
@caelyreth is already working on this.
Since Apr 2, 2026.
A-comments
A-statements
A-whitespace
C-bug
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
The code:
fn a() {
let v1 = 1;
;
let v2 = 2;
}
fn b() {
let v1 = 1;
;
let v2 = 2;
}
fn c() {
let v1 = 1;
; // comment
}
Output of rustfmt --check main.rs:
Diff in /tmp/main.rs:1:
fn a() {
let v1 = 1;
- ;
let v2 = 2;
}
Diff in /tmp/main.rs:7:
fn b() {
let v1 = 1;
-
- ;
let v2 = 2;
}
Diff in /tmp/main.rs:15:
fn c() {
- let v1 = 1;
-
- ; // comment
+ let v1 = 1; // comment
}
fn a is the expected case, in fn b an empty line is removed and in fn c the comment is placed on the same line as let v1 = 1; because there was a semicolon just before the start of the comment.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.