Merge pull request #6887 from roc-lang/in-layout-unit

This commit is contained in:
Ayaz 2024-07-07 17:22:56 -05:00 committed by GitHub
commit eca229e3d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3362,6 +3362,9 @@ fn layout_from_flat_type<'a>(
} }
} }
if sortables.is_empty() {
Cacheable(Ok(Layout::UNIT), criteria)
} else {
sortables.sort_by(|(label1, layout1), (label2, layout2)| { sortables.sort_by(|(label1, layout1), (label2, layout2)| {
cmp_fields(&env.cache.interner, label1, *layout1, label2, *layout2) cmp_fields(&env.cache.interner, label1, *layout1, label2, *layout2)
}); });
@ -3382,13 +3385,14 @@ fn layout_from_flat_type<'a>(
inner_repr.newtype() inner_repr.newtype()
} else { } else {
let layouts = Vec::from_iter_in(sortables.into_iter().map(|t| t.1), arena); let layouts = Vec::from_iter_in(sortables.into_iter().map(|t| t.1), arena);
LayoutRepr::Struct(layouts.into_bump_slice()).direct() LayoutRepr::struct_(layouts.into_bump_slice()).direct()
}; };
let result = Ok(env.cache.put_in(Layout { repr, semantic })); let result = Ok(env.cache.put_in(Layout { repr, semantic }));
Cacheable(result, criteria) Cacheable(result, criteria)
} }
}
Tuple(elems, ext_var) => { Tuple(elems, ext_var) => {
let mut criteria = CACHEABLE; let mut criteria = CACHEABLE;