Skip to content

Commit

Permalink
Bug 1874035 - Add custom Debug derives for bitflags with custom deriv…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
marco-c committed Feb 8, 2024
1 parent 8b286b0 commit 362a9bc
Show file tree
Hide file tree
Showing 8 changed files with 850 additions and 10 deletions.
95 changes: 94 additions & 1 deletion build/rust/bitflags/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ bitflags
as
bitflags2
;
pub
use
bitflags
:
:
parser
;
/
/
Copy
Expand Down Expand Up @@ -303,7 +310,6 @@ outer
[
derive
(
Debug
Clone
Copy
PartialEq
Expand All @@ -320,6 +326,93 @@ BitFlags
T
)
;
impl
core
:
:
fmt
:
:
Debug
for
BitFlags
{
fn
fmt
(
&
self
f
:
&
mut
core
:
:
fmt
:
:
Formatter
)
-
>
core
:
:
fmt
:
:
Result
{
if
self
.
is_empty
(
)
{
core
:
:
write
!
(
f
"
{
:
#
x
}
"
Self
:
:
empty
(
)
.
bits
(
)
)
}
else
{
crate
:
:
parser
:
:
to_writer
(
self
f
)
}
}
}
bitflags2
!
{
Expand Down
85 changes: 84 additions & 1 deletion gfx/wr/webrender/src/clip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6532,7 +6532,6 @@ Deserialize
[
derive
(
Debug
Copy
PartialEq
Eq
Expand Down Expand Up @@ -6575,6 +6574,90 @@ USE_FAST_PATH
;
}
}
impl
core
:
:
fmt
:
:
Debug
for
ClipNodeFlags
{
fn
fmt
(
&
self
f
:
&
mut
core
:
:
fmt
:
:
Formatter
)
-
>
core
:
:
fmt
:
:
Result
{
if
self
.
is_empty
(
)
{
write
!
(
f
"
{
:
#
x
}
"
Self
:
:
empty
(
)
.
bits
(
)
)
}
else
{
bitflags
:
:
parser
:
:
to_writer
(
self
f
)
}
}
}
/
/
When
Expand Down
85 changes: 84 additions & 1 deletion gfx/wr/webrender/src/gpu_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3470,7 +3470,6 @@ Deserialize
[
derive
(
Debug
Copy
PartialEq
Eq
Expand Down Expand Up @@ -3707,6 +3706,90 @@ FORCE_AA
;
}
}
impl
core
:
:
fmt
:
:
Debug
for
BrushFlags
{
fn
fmt
(
&
self
f
:
&
mut
core
:
:
fmt
:
:
Formatter
)
-
>
core
:
:
fmt
:
:
Result
{
if
self
.
is_empty
(
)
{
write
!
(
f
"
{
:
#
x
}
"
Self
:
:
empty
(
)
.
bits
(
)
)
}
else
{
bitflags
:
:
parser
:
:
to_writer
(
self
f
)
}
}
}
/
/
/
Expand Down

0 comments on commit 362a9bc

Please sign in to comment.