-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
std::repr does not work properly for packed fields #13486
Comments
eugh what a pain. I thought reflect was already doing this. |
Just a comment to give a code example of the issue (which doesn't appears to have been fixed): #[packed]
struct Packed {
a: u8,
b: u32,
c: [u8, ..3],
}
struct NonPacked {
a: u8,
b: u32,
c: [u8, ..3],
}
fn main() {
let p = Packed {
a: 1,
b: 3,
c: [3, 4, 5],
};
println!("{:?}", p);
let p = NonPacked {
a: 1,
b: 3,
c: [3, 4, 5],
};
println!("{:?}", p);
} Output:
My
|
Reflection has been removed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem with
std::repr
(and withstd::reflect
) is thatTyVisitor
does not tell whether struct is packed or not.I think, proper solution would be adding
offset
parameter tofn visit_class_field(...)
callback, to remove all complex offsets/alignment computation code from libstd (because it is already done in librustc).The text was updated successfully, but these errors were encountered: