New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please allow to use the "internal" derives in the "custom-derive" case #395
Comments
…es. r=gfx-reviewers,emilio,ErichDonGubler bitflags 2 has a shortcoming with using custom derives: you can't use custom derives (for e.g. MallocSizeOf) at the same time as bitflags's for the derives it supports. See bitflags/bitflags#395 Differential Revision: https://phabricator.services.mozilla.com/D199941
…es. r=gfx-reviewers,emilio,ErichDonGubler bitflags 2 has a shortcoming with using custom derives: you can't use custom derives (for e.g. MallocSizeOf) at the same time as bitflags's for the derives it supports. See bitflags/bitflags#395 Differential Revision: https://phabricator.services.mozilla.com/D199941 [ghsync] From https://hg.mozilla.org/mozilla-central/rev/45bd6cc1bf7490f80630afce7550706e9b064f81
…es. r=gfx-reviewers,emilio,ErichDonGubler bitflags 2 has a shortcoming with using custom derives: you can't use custom derives (for e.g. MallocSizeOf) at the same time as bitflags's for the derives it supports. See bitflags/bitflags#395 Differential Revision: https://phabricator.services.mozilla.com/D199941 UltraBlame original commit: 45bd6cc1bf7490f80630afce7550706e9b064f81
…es. r=gfx-reviewers,emilio,ErichDonGubler bitflags 2 has a shortcoming with using custom derives: you can't use custom derives (for e.g. MallocSizeOf) at the same time as bitflags's for the derives it supports. See bitflags/bitflags#395 Differential Revision: https://phabricator.services.mozilla.com/D199941 UltraBlame original commit: 45bd6cc1bf7490f80630afce7550706e9b064f81
…es. r=gfx-reviewers,emilio,ErichDonGubler bitflags 2 has a shortcoming with using custom derives: you can't use custom derives (for e.g. MallocSizeOf) at the same time as bitflags's for the derives it supports. See bitflags/bitflags#395 Differential Revision: https://phabricator.services.mozilla.com/D199941
Hi @glandium 👋 It looks like you're using the impl-style #[derive(bitflags::Debug, Foo, Bar)]
pub struct Qux(u32);
bitflags! {
impl Qux: u32 {
...
}
} |
It wouldn't need to be a proc macro, it should be possible to make this work: #[derive(....)]
pub struct Qux(u32);
bitflags! {
#[derive(Debug)}
impl Qux: u32 {
...
}
}
// produces the same Debug impl that this would produce:
// bitflags! {
// #[derive(Debug)]
// struct Qux: u32 {...}
// } |
Both would work, although the proc-macro would feel better because it groups the derive in a single place, but I can understand that it's more stuff to compile. |
My preference would be for a proc-macro, starting in an external library with the option to include in |
That's what bitflags 1 was doing. bitflags 2 is different in that matter, which is the reason for this issue in the first place. Specifically, it uses a newtype of an internal type that |
|
…es. r=gfx-reviewers,emilio,ErichDonGubler bitflags 2 has a shortcoming with using custom derives: you can't use custom derives (for e.g. MallocSizeOf) at the same time as bitflags's for the derives it supports. See bitflags/bitflags#395 Differential Revision: https://phabricator.services.mozilla.com/D199941 UltraBlame original commit: 45bd6cc1bf7490f80630afce7550706e9b064f81
…es. r=gfx-reviewers,emilio,ErichDonGubler bitflags 2 has a shortcoming with using custom derives: you can't use custom derives (for e.g. MallocSizeOf) at the same time as bitflags's for the derives it supports. See bitflags/bitflags#395 Differential Revision: https://phabricator.services.mozilla.com/D199941
In bitflags 1, it was possible to do something like
With bitflags 2, the equivalent is:
Unfortunately, that means
Debug
is derived normally, not using the nicer implementation that bitflags provides. One can implement it manually, but that quickly becomes cumbersome. It would be more useful if bitflags allowed to use some or all of its internal derives.The text was updated successfully, but these errors were encountered: