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
At the moment it's impossible for the compiler to reduce the bits-per-field of a struct containing booleans or small enums to less than 8, since that's the granularity of pointers and the language must assume that any field can have a reference taken to it. I suggest an annotation for structs and enums (and/or fields) that disallows users from referencing fields, forcing them to move out to the stack first. As an extension, this could be done automatically when possible, but sometimes it must be strictly illegal, such as when returning a borrow from a function. This would mean that a 2-variant enum would need a minimum of 1 bit to be represented, and stuff like bitfields could be created as a struct with bool fields, zero-cost.
The name is bikesheddable, since you can reference the value as long as it is stored on the stack (where it would be padded out to 1 byte minimum like usual).
The text was updated successfully, but these errors were encountered:
At the moment it's impossible for the compiler to reduce the bits-per-field of a struct containing booleans or small enums to less than 8, since that's the granularity of pointers and the language must assume that any field can have a reference taken to it. I suggest an annotation for structs and enums (and/or fields) that disallows users from referencing fields, forcing them to move out to the stack first. As an extension, this could be done automatically when possible, but sometimes it must be strictly illegal, such as when returning a borrow from a function. This would mean that a 2-variant enum would need a minimum of 1 bit to be represented, and stuff like bitfields could be created as a struct with bool fields, zero-cost.
The name is bikesheddable, since you can reference the value as long as it is stored on the stack (where it would be padded out to 1 byte minimum like usual).
The text was updated successfully, but these errors were encountered: