-
Notifications
You must be signed in to change notification settings - Fork 156
Emit more Cluster arrays as arrays instead of lists of elements. #534
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
Conversation
Add ArrayProxy for handling Cluster arrays that would be emitted as a rust array except for the need for padding between elements.
r? @ryankurte (rust-highfive has picked a reviewer for you, use r? to override) |
|
Make the usage of ArrayProxy dependent on the const_generics config option.
Thanks. The changes updated to rely on that option. |
bors r+ |
(This obsoletes #531)
Some Cluster arrays cannot be emitted as Rust (built-in) arrays due to padding between elements.
Add a helper zero-sized type
ArrayProxy
that overloads[]
to do pointer-arithmetic internally.I believe, although I'm not 100% confident, that I'm not breaking Rust safety, as follows: There is no way for (safe) code to create an
ArrayProxy
. Code that produces a (reference to) anArrayProxy
has to useunsafe
somewhere.See rcls/svd2rust-example@b8645fe for any example of the difference this makes (or does not make):
This uses const generics, so the new functionality requires the
--const_generic
command line optoin.