only expand recursive tag unions if it's a different type (think linked-list of trees)

This commit is contained in:
Folkert 2021-07-14 00:48:10 +02:00
parent 7701596469
commit 1bea704272
2 changed files with 7 additions and 2 deletions

View file

@ -1665,7 +1665,12 @@ pub fn union_sorted_tags_help<'a>(
has_any_arguments = true;
// make sure to not unroll recursive types!
if opt_rec_var.is_some() && is_recursive_tag_union(&layout) {
let self_recursion = opt_rec_var.is_some()
&& subs.get_root_key_without_compacting(var)
== subs.get_root_key_without_compacting(opt_rec_var.unwrap())
&& is_recursive_tag_union(&layout);
if self_recursion {
arg_layouts.push(Layout::RecursivePointer);
} else {
arg_layouts.push(layout);