Skip to content

Use derive macro instead of attribute macro #37

Closed
@hellow554

Description

@hellow554

Using a Derive Macro has the "advantage" that it plays nicely with the #[derive] attribute, whereas in the current form if you use #[bitflags] in the wrong order you get the following error message:

error[E0658]: macro attributes in `#[derive]` output are unstable
 --> src/game_types.rs:7:3
  |
7 | #[bitflags]
  |   ^^^^^^^^
  |
  = note: see issue #81119 <https://github.com/rust-lang/rust/issues/81119> for more information
  = help: add `#![feature(macro_attributes_in_derive_output)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.

You can still can have an attribute #[bitflags(default = B | C)] with the help of the attributes argument inside of the proc_macro_derive macro (https://doc.rust-lang.org/reference/procedural-macros.html#derive-macro-helper-attributes)


Was there a specific reason for not using #[derive(Bitflags)] in the first place?

Would you concider upgrading to the derive attribute? Would you accept a PR that does that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions