rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

`merge_derives` removes trailing comments on multi-line derives

Open spectria-limina opened this issue 2 years ago • 1 comments

Without merge_derives, rustfmt leaves the following code as-is:

#[repr(u8)]
#[derive(
    Copy,
    Clone,
    Component,
    Serialize,
    Deserialize,
    Debug,
    Hash,
    PartialOrd,
    Ord,
    PartialEq,
    Eq,
    IntEnum,
    Sequence,
    Reflect,
)]
pub struct Waymark {}

Actual behaviour:

With merge_derives, however, the trailing comma after Reflect is removed.

Expected behaviour

The presence or absence of a trailing comma should not be dependent on merge_derives.

Notes

This isn't that big a deal, because the whole point of turning this option on is to avoid vertical derive layout.

spectria-limina avatar Feb 02 '24 16:02 spectria-limina

@spectria-limina Thanks for reaching out. I'm having trouble reproducing the trailing comma issue that you've described. Are there maybe other configuration options that you're using? merge_derives=true is configured by default. It would also be helpful to know what version of rustfmt you're using.

ytmimi avatar Feb 07 '24 02:02 ytmimi