correct alignment in records!

This commit is contained in:
Folkert 2020-11-24 21:28:53 +01:00
parent 517f8f4a4a
commit 1e4f0e8b07
4 changed files with 42 additions and 26 deletions

View file

@ -927,7 +927,20 @@ fn sort_record_fields_help<'a>(
}
}
sorted_fields.sort_by(|(label1, _, _), (label2, _, _)| label1.cmp(label2));
sorted_fields.sort_by(
|(label1, _, res_layout1), (label2, _, res_layout2)| match res_layout1 {
Ok(layout1) | Err(layout1) => match res_layout2 {
Ok(layout2) | Err(layout2) => {
let ptr_bytes = 8;
let size1 = layout1.alignment_bytes(ptr_bytes);
let size2 = layout2.alignment_bytes(ptr_bytes);
size2.cmp(&size1).then(label1.cmp(label2))
}
},
},
);
sorted_fields
}