You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix DekuRead for #[repr(...)] enums constructed using id via ctx and whose variants assign discriminant values (sharksforarms#577)
* deku-derive: Derive Clone, Copy for ReprType
ReprType is a simple enum; copy and clone operations have the same cost
as forming pointers, so let's allow them to reduce some source noise.
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
* deku-derive: Prune discriminant error paths with let-else
Reduce indentation and improve readability by eliminating the match
expression. Also, in my opinion, describing the constraints on the goal
in a linear fashion makes the code easier to reason about.
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
* deku-derive: Drop redundant <T>::try_from() for discriminant access
The unsafe expression already dereferences the pointer cast to the
target type.
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
* deku-derive: emit_enum(): Prefer repr over id_type for conversions
Use of the `id` attribute in enum contexts precludes use of
`id_type`, under which condition id_type is None. A None id_type
breaks the generated token stream at the point of the cast in the unsafe
expression accessing the discriminant value.
However, we must have a valid `repr` and that repr must match id_type
where it's present, by elimination of paths to the contrary in the
existing error handling. Emit the token for the repr type in place of
id_type for the purpose of the type conversion logic.
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
---------
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
Co-authored-by: Emmanuel Thompson <ethompson@fastly.com>
0 commit comments