mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
pass along the specific pool we're adding to
This commit is contained in:
parent
1814a69c30
commit
722ae9da6b
1 changed files with 16 additions and 16 deletions
|
@ -3023,7 +3023,8 @@ fn deep_copy_var_in(
|
||||||
) -> Variable {
|
) -> Variable {
|
||||||
let mut visited = bumpalo::collections::Vec::with_capacity_in(256, arena);
|
let mut visited = bumpalo::collections::Vec::with_capacity_in(256, arena);
|
||||||
|
|
||||||
let copy = deep_copy_var_help(subs, rank, pools, &mut visited, var);
|
let pool = pools.get_mut(rank);
|
||||||
|
let copy = deep_copy_var_help(subs, rank, pool, &mut visited, var);
|
||||||
|
|
||||||
// we have tracked all visited variables, and can now traverse them
|
// we have tracked all visited variables, and can now traverse them
|
||||||
// in one go (without looking at the UnificationTable) and clear the copy field
|
// in one go (without looking at the UnificationTable) and clear the copy field
|
||||||
|
@ -3050,7 +3051,7 @@ fn has_trivial_copy(subs: &Subs, root_var: Variable) -> Option<Variable> {
|
||||||
fn deep_copy_var_help(
|
fn deep_copy_var_help(
|
||||||
subs: &mut Subs,
|
subs: &mut Subs,
|
||||||
max_rank: Rank,
|
max_rank: Rank,
|
||||||
pools: &mut Pools,
|
pool: &mut Vec<Variable>,
|
||||||
visited: &mut bumpalo::collections::Vec<'_, Variable>,
|
visited: &mut bumpalo::collections::Vec<'_, Variable>,
|
||||||
var: Variable,
|
var: Variable,
|
||||||
) -> Variable {
|
) -> Variable {
|
||||||
|
@ -3065,15 +3066,14 @@ fn deep_copy_var_help(
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
visited.push(var);
|
|
||||||
|
|
||||||
// Safety: Here we make a variable that is 1 position out of bounds.
|
// Safety: Here we make a variable that is 1 position out of bounds.
|
||||||
// The reason is that we can now keep the mutable reference to `desc`
|
// The reason is that we can now keep the mutable reference to `desc`
|
||||||
// Below, we actually push a new variable onto subs meaning the `copy`
|
// Below, we actually push a new variable onto subs meaning the `copy`
|
||||||
// variable is in-bounds before it is ever used.
|
// variable is in-bounds before it is ever used.
|
||||||
let copy = unsafe { Variable::from_index(subs_len as u32) };
|
let copy = unsafe { Variable::from_index(subs_len as u32) };
|
||||||
|
|
||||||
pools.get_mut(max_rank).push(copy);
|
visited.push(var);
|
||||||
|
pool.push(copy);
|
||||||
|
|
||||||
// Link the original variable to the new variable. This lets us
|
// Link the original variable to the new variable. This lets us
|
||||||
// avoid making multiple copies of the variable we are instantiating.
|
// avoid making multiple copies of the variable we are instantiating.
|
||||||
|
@ -3099,7 +3099,7 @@ fn deep_copy_var_help(
|
||||||
let new_variables = SubsSlice::reserve_into_subs(subs, $length as _);
|
let new_variables = SubsSlice::reserve_into_subs(subs, $length as _);
|
||||||
for (target_index, var_index) in (new_variables.indices()).zip($variables) {
|
for (target_index, var_index) in (new_variables.indices()).zip($variables) {
|
||||||
let var = subs[var_index];
|
let var = subs[var_index];
|
||||||
let copy_var = deep_copy_var_help(subs, max_rank, pools, visited, var);
|
let copy_var = deep_copy_var_help(subs, max_rank, pool, visited, var);
|
||||||
subs.variables[target_index] = copy_var;
|
subs.variables[target_index] = copy_var;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3120,9 +3120,9 @@ fn deep_copy_var_help(
|
||||||
}
|
}
|
||||||
|
|
||||||
Func(arguments, closure_var, ret_var) => {
|
Func(arguments, closure_var, ret_var) => {
|
||||||
let new_ret_var = deep_copy_var_help(subs, max_rank, pools, visited, ret_var);
|
let new_ret_var = deep_copy_var_help(subs, max_rank, pool, visited, ret_var);
|
||||||
let new_closure_var =
|
let new_closure_var =
|
||||||
deep_copy_var_help(subs, max_rank, pools, visited, closure_var);
|
deep_copy_var_help(subs, max_rank, pool, visited, closure_var);
|
||||||
|
|
||||||
let new_arguments = copy_sequence!(arguments.len(), arguments);
|
let new_arguments = copy_sequence!(arguments.len(), arguments);
|
||||||
|
|
||||||
|
@ -3145,7 +3145,7 @@ fn deep_copy_var_help(
|
||||||
|
|
||||||
Record(
|
Record(
|
||||||
record_fields,
|
record_fields,
|
||||||
deep_copy_var_help(subs, max_rank, pools, visited, ext_var),
|
deep_copy_var_help(subs, max_rank, pool, visited, ext_var),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3162,14 +3162,14 @@ fn deep_copy_var_help(
|
||||||
|
|
||||||
let union_tags = UnionTags::from_slices(tags.tag_names(), new_variable_slices);
|
let union_tags = UnionTags::from_slices(tags.tag_names(), new_variable_slices);
|
||||||
|
|
||||||
let new_ext = deep_copy_var_help(subs, max_rank, pools, visited, ext_var);
|
let new_ext = deep_copy_var_help(subs, max_rank, pool, visited, ext_var);
|
||||||
TagUnion(union_tags, new_ext)
|
TagUnion(union_tags, new_ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionOrTagUnion(tag_name, symbol, ext_var) => FunctionOrTagUnion(
|
FunctionOrTagUnion(tag_name, symbol, ext_var) => FunctionOrTagUnion(
|
||||||
tag_name,
|
tag_name,
|
||||||
symbol,
|
symbol,
|
||||||
deep_copy_var_help(subs, max_rank, pools, visited, ext_var),
|
deep_copy_var_help(subs, max_rank, pool, visited, ext_var),
|
||||||
),
|
),
|
||||||
|
|
||||||
RecursiveTagUnion(rec_var, tags, ext_var) => {
|
RecursiveTagUnion(rec_var, tags, ext_var) => {
|
||||||
|
@ -3185,8 +3185,8 @@ fn deep_copy_var_help(
|
||||||
|
|
||||||
let union_tags = UnionTags::from_slices(tags.tag_names(), new_variable_slices);
|
let union_tags = UnionTags::from_slices(tags.tag_names(), new_variable_slices);
|
||||||
|
|
||||||
let new_ext = deep_copy_var_help(subs, max_rank, pools, visited, ext_var);
|
let new_ext = deep_copy_var_help(subs, max_rank, pool, visited, ext_var);
|
||||||
let new_rec_var = deep_copy_var_help(subs, max_rank, pools, visited, rec_var);
|
let new_rec_var = deep_copy_var_help(subs, max_rank, pool, visited, rec_var);
|
||||||
|
|
||||||
RecursiveTagUnion(new_rec_var, union_tags, new_ext)
|
RecursiveTagUnion(new_rec_var, union_tags, new_ext)
|
||||||
}
|
}
|
||||||
|
@ -3203,7 +3203,7 @@ fn deep_copy_var_help(
|
||||||
opt_name,
|
opt_name,
|
||||||
structure,
|
structure,
|
||||||
} => {
|
} => {
|
||||||
let new_structure = deep_copy_var_help(subs, max_rank, pools, visited, structure);
|
let new_structure = deep_copy_var_help(subs, max_rank, pool, visited, structure);
|
||||||
|
|
||||||
let content = RecursionVar {
|
let content = RecursionVar {
|
||||||
opt_name,
|
opt_name,
|
||||||
|
@ -3237,7 +3237,7 @@ fn deep_copy_var_help(
|
||||||
};
|
};
|
||||||
|
|
||||||
let new_real_type_var =
|
let new_real_type_var =
|
||||||
deep_copy_var_help(subs, max_rank, pools, visited, real_type_var);
|
deep_copy_var_help(subs, max_rank, pool, visited, real_type_var);
|
||||||
let new_content = Alias(symbol, new_arguments, new_real_type_var, kind);
|
let new_content = Alias(symbol, new_arguments, new_real_type_var, kind);
|
||||||
|
|
||||||
subs.set_content_unchecked(copy, new_content);
|
subs.set_content_unchecked(copy, new_content);
|
||||||
|
@ -3246,7 +3246,7 @@ fn deep_copy_var_help(
|
||||||
}
|
}
|
||||||
|
|
||||||
RangedNumber(typ, range_vars) => {
|
RangedNumber(typ, range_vars) => {
|
||||||
let new_type_var = deep_copy_var_help(subs, max_rank, pools, visited, typ);
|
let new_type_var = deep_copy_var_help(subs, max_rank, pool, visited, typ);
|
||||||
|
|
||||||
let new_variables = copy_sequence!(range_vars.len(), range_vars);
|
let new_variables = copy_sequence!(range_vars.len(), range_vars);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue