Closed
Description
rustfmt 1.4.12-nightly (9f53665f 2020-02-10)
rustc 1.44.0-nightly (f509b26a7 2020-03-18)
Minimal repro
- Prepare the nightly repos:
cargo new aaa
cd aaa
echo 'nightly' > rust-toolchain
- Prepare the
.rustfmt.toml
:
struct_field_align_threshold = 127
trailing_comma = "Never"
- Prepare the
src/main.rs
with astruct
like it:
struct S {
aaa: f32,
bbb: f32,
ccc: f32
}
fn main() {
println!("Hello, world!");
}
cargo fmt
The actual result of src/main.rs
:
struct S {
aaa: f32
bbb: f32
ccc: f32
}
fn main() {
println!("Hello, world!");
}
Note: The commas are removed. Unfortunately, this result could not be compiled then I think it is high priority bug maybe.
The Expected result of src/main.rs
:
struct S {
aaa: f32,
bbb: f32,
ccc: f32
}
fn main() {
println!("Hello, world!");
}
Note: I tried some different versions of the minimal repro code. So, I found two variations that could be format expectedly.
- The No empty lines pattern:
struct S {
aaa: f32,
bbb: f32,
ccc: f32
}
- No White space characters pattern:
struct S {
aaa: f32,
bbb: f32,
ccc: f32
}
Note: These variant patterns be retained these commas cargo fmt
once. However, once again cargo fmt
, then these are removed.