Rustfmt: malformed `derive` attribute input deletes derive arguments

Created on 23 Nov 2020  路  3Comments  路  Source: rust-lang/rustfmt

Describe the bug
Adding a generic type to a derive macro deletes all derives

To Reproduce

cat <<EOF | rustfmt
#[derive(Debug, Foo<T>)]
enum Bar{}
EOF 


This produces the following output, removing all derive attributes:

#[derive()]
enum Bar {}

Expected behavior
Something less nefarious, like rustc's

error: malformed `derive` attribute input

Meta

  • rustfmt version: rustrustfmt 1.4.24-stable (eb894d5 2020-11-05)
  • From where did you install rustfmt?: rustup
  • How do you run rustfmt: In an editor with undo hopefully :smiling_imp:
bug duplicate

Most helpful comment

This has been fixed in source but not backported to a released version. Will try to do so for the upcoming 1.4.28 release

All 3 comments

Just noticed this as well:

#[derive(Debug, , Default)]
struct Struct(i32);

turns into this:

#[derive()]
struct Struct(i32);

which is bizarre when you're deleting one of the derives and you save partway through!

This has been fixed in source but not backported to a released version. Will try to do so for the upcoming 1.4.28 release

Closing as a duplicate of #3898, fix has been backported and will be in the next release

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scampi picture scampi  路  4Comments

MoSal picture MoSal  路  5Comments

Diggsey picture Diggsey  路  4Comments

torkleyy picture torkleyy  路  5Comments

thomaseizinger picture thomaseizinger  路  3Comments