Make is_recursive_tag_union a method on Layout

This commit is contained in:
Richard Feldman 2022-11-12 20:57:04 -05:00
parent 746b2fdeb1
commit 56f33c4e1c
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B

View file

@ -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);