rustfmt
rustfmt copied to clipboard
Vector declarations with trailing commas don't get formatted
I noticed some odd behaviour with rustfmt (0.5.0). It leaves vector declarations with trailing commas untouched. The following code
fn main() {
let arr_x = [ 1, 2, 3 ];
let arr_y = [ 1, 2, 3, ];
let vec_x = vec![ 1, 2, 3 ];
let vec_y = vec![ 1, 2, 3, ];
}
becomes
fn main() {
let arr_x = [1, 2, 3];
let arr_y = [1, 2, 3];
let vec_x = vec![1, 2, 3];
let vec_y = vec![ 1, 2, 3, ];
}
Is this a bug or a feature?
It's kind of a bug - we only reformat macro uses if they look like function calls, and a trailing comma breaks that, I guess.
This was considered. There's no way to guarantee that the trailing comma is not significant.
Closed by #1219.