mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
correct alignment in records!
This commit is contained in:
parent
517f8f4a4a
commit
1e4f0e8b07
4 changed files with 42 additions and 26 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue