Description
Both in relation to defining and instantiating structs, if the last field does not have a trailing comma, then rustfmt inserts one. However, if a comment is subsequently present, then it is moved up as well.
If the comma was already present, then the comment is not moved.
Before:
struct Foo {
bar: ()
// Comment
}
struct Bar {
baz: ()
/*
Comment
*/
}
struct Baz(
()
// Comment
);
fn main() {
let _ = Foo {
bar: ()
/*
Comment
*/
};
let _ = Bar {
baz: ()
/*
Comment
*/
};
let _ = Baz(
()
// Comment
);
}
After:
struct Foo {
bar: (), // Comment
}
struct Bar {
baz: (), /*
Comment
*/
}
struct Baz(
(), // Comment
);
fn main() {
let _ = Foo {
bar: (), /*
Comment
*/
};
let _ = Bar {
baz: (), /*
Comment
*/
};
let _ = Baz(
(), // Comment
);
}