Skip to content

Commit

Permalink
Bug 1613517 - Make rust generate better code for derive(Animate) and …
Browse files Browse the repository at this point in the history
…derive(ComputeSquaredDistance). r=heycam

See rust-lang/rust#68867.

This technically changes the semantics of #[animate(fallback)] and such when
combined with #[animate(error)]. But no such combination exists and the new
semantics are perfectly reasonable as well, IMHO.

Differential Revision: https://phabricator.services.mozilla.com/D61761

UltraBlame original commit: bd4711d31ec6ab173b77406cb4ede0fa7a484af3
  • Loading branch information
marco-c committed Feb 12, 2020
1 parent e6e0bfa commit cf7c1dc
Show file tree
Hide file tree
Showing 2 changed files with 420 additions and 321 deletions.
229 changes: 120 additions & 109 deletions servo/components/style_derive/animate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ input
)
;
let
input_attrs
=
cg
:
:
parse_input_attrs
:
:
<
AnimateInputAttrs
>
(
&
input
)
;
let
no_bound
=
animation_input_attrs
Expand Down Expand Up @@ -167,7 +184,7 @@ let
(
mut
match_body
append_error_clause
needs_catchall_branch
)
=
{
Expand All @@ -184,8 +201,7 @@ input
)
;
let
mut
append_error_clause
needs_catchall_branch
=
s
.
Expand Down Expand Up @@ -226,39 +242,13 @@ variant
let
arm
=
match
derive_variant_arm
(
variant
&
mut
where_clause
)
{
Ok
(
arm
)
=
>
arm
Err
(
(
)
)
=
>
{
append_error_clause
=
true
;
return
body
;
}
}
;
quote
!
Expand All @@ -273,7 +263,7 @@ arm
;
(
match_body
append_error_clause
needs_catchall_branch
)
}
;
Expand All @@ -286,35 +276,7 @@ where_clause
where_clause
;
if
append_error_clause
{
let
input_attrs
=
cg
:
:
parse_input_attrs
:
:
<
AnimateInputAttrs
>
(
&
input
)
;
if
let
Some
(
fallback
)
=
input_attrs
.
fallback
needs_catchall_branch
{
match_body
.
Expand All @@ -323,45 +285,20 @@ append_all
quote
!
{
(
this
other
)
_
=
>
#
fallback
(
this
other
procedure
)
}
)
;
}
else
unsafe
{
match_body
.
append_all
(
quote
debug_unreachable
!
{
_
=
>
Err
(
(
)
)
}
}
)
;
}
}
let
name
=
Expand All @@ -385,6 +322,45 @@ split_for_impl
(
)
;
let
fallback
=
match
input_attrs
.
fallback
{
Some
(
fallback
)
=
>
quote
!
{
#
fallback
(
self
other
procedure
)
}
None
=
>
quote
!
{
Err
(
(
)
)
}
}
;
quote
!
{
Expand Down Expand Up @@ -452,6 +428,35 @@ Self
)
>
{
if
std
:
:
mem
:
:
discriminant
(
self
)
!
=
std
:
:
mem
:
:
discriminant
(
other
)
{
return
#
fallback
;
}
match
(
self
Expand Down Expand Up @@ -483,12 +488,7 @@ WhereClause
)
-
>
Result
<
TokenStream
(
)
>
{
let
variant_attrs
Expand All @@ -511,19 +511,6 @@ ast
)
)
;
if
variant_attrs
.
error
{
return
Err
(
(
)
)
;
}
let
(
this_pattern
Expand Down Expand Up @@ -560,6 +547,33 @@ other
"
)
;
if
variant_attrs
.
error
{
return
quote
!
{
(
&
#
this_pattern
&
#
other_pattern
)
=
>
Err
(
(
)
)
}
;
}
let
(
result_value
Expand Down Expand Up @@ -775,8 +789,6 @@ procedure
)
)
;
Ok
(
quote
!
{
Expand All @@ -800,7 +812,6 @@ result_value
)
}
}
)
}
#
[
Expand Down
Loading

0 comments on commit cf7c1dc

Please sign in to comment.