rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
6.06k stars 892 forks source link

`merge_derives` removes trailing comments on multi-line derives #6053

Open spectria-limina opened 10 months ago

spectria-limina commented 10 months ago

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.

ytmimi commented 10 months ago

@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.