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 1, 2024
1 parent c828b0c commit 1c4d90d
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 @@ -7,6 +7,13 @@ bitflags
as
bitflags2
;
pub
use
bitflags
:
:
parser
;
#
[
macro_export
Expand Down Expand Up @@ -95,7 +102,6 @@ outer
[
derive
(
Debug
Clone
Copy
PartialEq
Expand All @@ -112,6 +118,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 @@ -3531,7 +3531,6 @@ Deserialize
[
derive
(
Debug
Copy
PartialEq
Eq
Expand Down Expand Up @@ -3574,6 +3573,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
)
}
}
}
#
[
derive
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 @@ -2914,7 +2914,6 @@ Deserialize
[
derive
(
Debug
Copy
PartialEq
Eq
Expand Down Expand Up @@ -3151,6 +3150,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
)
}
}
}
pub
struct
BrushInstance
Expand Down

0 comments on commit 1c4d90d

Please sign in to comment.