rust-lang / rustfmt

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

remove stray comma from cfg-attr allow() #3228

Open matthiaskrgr opened 6 years ago

matthiaskrgr commented 6 years ago

#![cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always,)] could be formatted to #![cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always)].

Note that this already works for just #![allow(nline_always,)]

rustfmt 1.0.0-nightly (43206f4 2018-11-30)

ytmimi commented 2 years ago

Confirming I can reproduce with rustfmt 1.5.1-nightly (b22884f7 2022-07-19)

input

#![cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always,))]
#![allow(nline_always,)]

output

#![cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always,))]
#![allow(nline_always)]
ytmimi commented 2 years ago

I understand that this isn't the intended result from this issue, but we don't want to remove trailing commas if they are present in the source text. The current behavior in the #![allow(nline_always,)] case is a bug. I just checked and #5394 resolves removing the trailing comma in the #![allow(nline_always,)]