diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index 7ec8f89a3b..d80ce61f04 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -1044,7 +1044,6 @@ pub fn build_exp_expr<'a, 'ctx, 'env>( tag_layout: Layout::Union(UnionLayout::NullableWrapped { nullable_id, - nullable_layout: _, other_tags: fields, }), union_size, diff --git a/compiler/mono/src/decision_tree.rs b/compiler/mono/src/decision_tree.rs index 298740ad84..aab20c55be 100644 --- a/compiler/mono/src/decision_tree.rs +++ b/compiler/mono/src/decision_tree.rs @@ -1014,16 +1014,17 @@ fn path_to_expr_help<'a>( NonRecursive(layouts) | Recursive(layouts) => layouts[*tag_id as usize], NullableWrapped { nullable_id, - nullable_layout, other_tags: layouts, .. } => { use std::cmp::Ordering; dbg!(nullable_id, tag_id); match (*tag_id as usize).cmp(&(*nullable_id as usize)) { - Ordering::Equal => &*env + Ordering::Equal => + // the nullable tag is going to predent it stores a tag id + &*env .arena - .alloc([Layout::Builtin(nullable_layout.clone())]), + .alloc([Layout::Builtin(crate::layout::TAG_SIZE)]), Ordering::Less => layouts[*tag_id as usize], Ordering::Greater => layouts[*tag_id as usize - 1], } diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index e55c86c173..0e73bae523 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -2823,7 +2823,6 @@ pub fn with_hole<'a>( let layout = Layout::Union(UnionLayout::NullableWrapped { nullable_id, - nullable_layout: TAG_SIZE, other_tags: layouts.into_bump_slice(), }); @@ -6169,7 +6168,6 @@ fn from_can_pattern_help<'a>( let layout = Layout::Union(UnionLayout::NullableWrapped { nullable_id, - nullable_layout: TAG_SIZE, other_tags: layouts.into_bump_slice(), }); diff --git a/compiler/mono/src/layout.rs b/compiler/mono/src/layout.rs index 2188a10f63..9fb5c7730e 100644 --- a/compiler/mono/src/layout.rs +++ b/compiler/mono/src/layout.rs @@ -50,12 +50,11 @@ pub enum UnionLayout<'a> { /// see also: https://youtu.be/ip92VMpf_-A?t=164 NullableWrapped { nullable_id: i64, - nullable_layout: Builtin<'a>, other_tags: &'a [&'a [Layout<'a>]], }, // A recursive tag union where the non-nullable variant does NOT store the tag id // e.g. `ConsList a : [ Nil, Cons a (ConsList a) ]` - // NullableUnwrapped, + // NullableUnwrapped { nullable_id: bool, other_id: bool, other_fields: &'a [Layout<'a>], } } #[derive(Clone, Debug, PartialEq, Eq, Hash)] @@ -1090,14 +1089,14 @@ fn layout_from_flat_type<'a>( if GENERATE_NULLABLE { for (index, (_name, variables)) in tags_vec.iter().enumerate() { if variables.is_empty() { - nullable = Some((index as i64, TAG_SIZE)); + nullable = Some(index as i64); break; } } } for (index, (_name, variables)) in tags_vec.into_iter().enumerate() { - if matches!(nullable, Some((i, _)) if i == index as i64) { + if matches!(nullable, Some(i) if i == index as i64) { // don't add the continue; } @@ -1129,10 +1128,9 @@ fn layout_from_flat_type<'a>( tag_layouts.push(tag_layout.into_bump_slice()); } - let union_layout = if let Some((tag_id, tag_id_layout)) = nullable { + let union_layout = if let Some(tag_id) = nullable { UnionLayout::NullableWrapped { nullable_id: tag_id, - nullable_layout: tag_id_layout, other_tags: tag_layouts.into_bump_slice(), } } else { @@ -1607,7 +1605,6 @@ pub fn layout_from_tag_union<'a>( Layout::Union(UnionLayout::NullableWrapped { nullable_id, - nullable_layout: TAG_SIZE, other_tags: tag_layouts.into_bump_slice(), }) }