mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
Unwrap the struct inside a single-tag union
This commit is contained in:
parent
2337d6638e
commit
cdce98d14f
2 changed files with 23 additions and 11 deletions
|
@ -547,7 +547,13 @@ pub fn layout_from_tag_union<'a>(
|
|||
Unit => Layout::Struct(&[]),
|
||||
BoolUnion { .. } => Layout::Builtin(Builtin::Int1),
|
||||
ByteUnion(_) => Layout::Builtin(Builtin::Int8),
|
||||
Unwrapped(field_layouts) => Layout::Struct(field_layouts.into_bump_slice()),
|
||||
Unwrapped(mut field_layouts) => {
|
||||
if field_layouts.len() == 1 {
|
||||
field_layouts.pop().unwrap()
|
||||
} else {
|
||||
Layout::Struct(field_layouts.into_bump_slice())
|
||||
}
|
||||
}
|
||||
Wrapped(tags) => {
|
||||
let mut tag_layouts = Vec::with_capacity_in(tags.len(), arena);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue