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.
The code:
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 ais the expected case, infn ban empty line is removed and infn cthe comment is placed on the same line aslet v1 = 1;because there was a semicolon just before the start of the comment.