mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Make is_recursive_tag_union a method on Layout
This commit is contained in:
parent
746b2fdeb1
commit
56f33c4e1c
1 changed files with 13 additions and 13 deletions
|
@ -2795,6 +2795,18 @@ impl<'a> Layout<'a> {
|
|||
Dec => Layout::i128(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_recursive_tag_union(self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Layout::Union(
|
||||
UnionLayout::NullableUnwrapped { .. }
|
||||
| UnionLayout::Recursive(_)
|
||||
| UnionLayout::NullableWrapped { .. }
|
||||
| UnionLayout::NonNullableUnwrapped { .. },
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Builtin<'a> {
|
||||
|
@ -3465,18 +3477,6 @@ fn get_recursion_var(subs: &Subs, var: Variable) -> Option<Variable> {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_recursive_tag_union(layout: &Layout) -> bool {
|
||||
matches!(
|
||||
layout,
|
||||
Layout::Union(
|
||||
UnionLayout::NullableUnwrapped { .. }
|
||||
| UnionLayout::Recursive(_)
|
||||
| UnionLayout::NullableWrapped { .. }
|
||||
| UnionLayout::NonNullableUnwrapped { .. },
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fn union_sorted_non_recursive_tags_help<'a, L>(
|
||||
env: &mut Env<'a, '_>,
|
||||
tags_list: &[(&'_ L, &[Variable])],
|
||||
|
@ -3755,7 +3755,7 @@ where
|
|||
== env
|
||||
.subs
|
||||
.get_root_key_without_compacting(opt_rec_var.unwrap())
|
||||
&& is_recursive_tag_union(&layout);
|
||||
&& layout.is_recursive_tag_union();
|
||||
|
||||
if self_recursion {
|
||||
arg_layouts.push(Layout::RecursivePointer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue