Skip to content

malformed derive attribute input deletes derive arguments #4545

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
ratmice opened this issue Nov 23, 2020 · 3 comments
Closed

malformed derive attribute input deletes derive arguments #4545

ratmice opened this issue Nov 23, 2020 · 3 comments
Labels
bug Panic, non-idempotency, invalid code, etc. duplicate

Comments

@ratmice
Copy link

ratmice commented Nov 23, 2020

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 😈
@ratmice ratmice added the bug Panic, non-idempotency, invalid code, etc. label Nov 23, 2020
@camelid
Copy link
Member

camelid commented Nov 24, 2020

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!

@calebcartwright
Copy link
Member

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

@calebcartwright
Copy link
Member

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Panic, non-idempotency, invalid code, etc. duplicate
Projects
None yet
Development

No branches or pull requests

3 participants