Merge branch 'trunk' into unit-types

This commit is contained in:
Richard Feldman 2020-03-19 22:05:22 -04:00 committed by GitHub
commit b33af811d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 156 additions and 53 deletions

View file

@ -496,26 +496,14 @@ pub fn build_expr<'a, 'ctx, 'env>(
}
Access {
label,
field_layout,
struct_layout: Layout::Struct(fields),
struct_layout: Layout::Struct(sorted_fields),
record,
..
} => {
let builder = env.builder;
// Reconstruct struct layout
let mut reconstructed_struct_layout =
Vec::with_capacity_in(fields.len() + 1, env.arena);
for field in fields.iter() {
reconstructed_struct_layout.push(field.clone());
}
reconstructed_struct_layout.push((label.clone(), field_layout.clone()));
reconstructed_struct_layout.sort_by(|a, b| {
a.0.partial_cmp(&b.0)
.expect("TODO: failed to sort struct fields in crane access")
});
// Get index
let index = reconstructed_struct_layout
let index = sorted_fields
.iter()
.position(|(local_label, _)| local_label == label)
.unwrap() as u32; // TODO