-
Notifications
You must be signed in to change notification settings - Fork 162
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
Support align and packed repr layout on structs #1188
Conversation
= meta_items->get_items ().at (0)->as_string (); | ||
|
||
// TODO: it would probably be better to make the MetaItems more aware | ||
// of constructs with nesting like #[repr(packed(2))] rather than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah i think your right here the AST Meta stuff is not very helpful to work with at the moment.
// parsing the #[repr] attribute. | ||
unsigned char align = 0; | ||
unsigned char pack = 0; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be worth having some kind of error node state here. For example, during the type-checking of this structure, you could represent an error state by a flag or something so that when you are compiling the type we know if it's ok or not so we can error or ignore the options. This will only really matter down the line when we get rid of the saw_errors guards between each compiler pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work LGTM
Lets see if you can bors this. I changed your permissions last time to try and fix it again, permissions are confusing lol |
bors r+ |
looks like its working!! @dafaust nice :D |
🎉 hooray :P |
Build succeeded: |
This is a start at handling the various layout options supported by Rust, beginning with
#[repr(align(N))]
and#[repr(packed(N))]
, on structs and tuple structs.There are several other layout options which remain to be supported such as
#[repr(C)]
,#[repr(transparent)]
, combinations e.g.#[repr(C, packed(2))]
, as well as layouts on union and enum types.Fixes: #915