pass along the specific pool we're adding to

This commit is contained in:
Folkert 2022-05-21 14:45:45 +02:00
parent 1814a69c30
commit 722ae9da6b
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -3023,7 +3023,8 @@ fn deep_copy_var_in(
) -> Variable {
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
// 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(
subs: &mut Subs,
max_rank: Rank,
pools: &mut Pools,
pool: &mut Vec<Variable>,
visited: &mut bumpalo::collections::Vec<'_, Variable>,
var: Variable,
) -> Variable {
@ -3065,15 +3066,14 @@ fn deep_copy_var_help(
return copy;
}
visited.push(var);
// 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`
// Below, we actually push a new variable onto subs meaning the `copy`
// variable is in-bounds before it is ever used.
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
// 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 _);
for (target_index, var_index) in (new_variables.indices()).zip($variables) {
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;
}
@ -3120,9 +3120,9 @@ fn deep_copy_var_help(
}
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 =
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);
@ -3145,7 +3145,7 @@ fn deep_copy_var_help(
Record(
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 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)
}
FunctionOrTagUnion(tag_name, symbol, ext_var) => FunctionOrTagUnion(
tag_name,
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) => {
@ -3185,8 +3185,8 @@ fn deep_copy_var_help(
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_rec_var = deep_copy_var_help(subs, max_rank, pools, visited, rec_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, pool, visited, rec_var);
RecursiveTagUnion(new_rec_var, union_tags, new_ext)
}
@ -3203,7 +3203,7 @@ fn deep_copy_var_help(
opt_name,
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 {
opt_name,
@ -3237,7 +3237,7 @@ fn deep_copy_var_help(
};
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);
subs.set_content_unchecked(copy, new_content);
@ -3246,7 +3246,7 @@ fn deep_copy_var_help(
}
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);