Merge pull request #3170 from rtfeldman/remove-restore

Remove Subs::restore
This commit is contained in:
Folkert de Vries 2022-06-02 20:22:02 +02:00 committed by GitHub
commit 4dee0e8129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 109 deletions

View File

@ -1636,8 +1636,6 @@ fn instantiate_rigids_help(
fn deep_copy_var(subs: &mut Subs, rank: Rank, pools: &mut Pools, var: Variable) -> Variable {
let copy = deep_copy_var_help(subs, rank, pools, var);
subs.restore(var);
copy
}

View File

@ -1881,10 +1881,6 @@ impl Subs {
(var_to_err_type(self, &mut state, var), state.problems)
}
pub fn restore(&mut self, var: Variable) {
restore_help(self, var)
}
pub fn len(&self) -> usize {
self.utable.len()
}
@ -3675,109 +3671,6 @@ fn get_fresh_var_name(state: &mut ErrorTypeState) -> Lowercase {
name
}
fn restore_help(subs: &mut Subs, initial: Variable) {
let mut stack = vec![initial];
let variable_slices = &subs.variable_slices;
let variables = &subs.variables;
let var_slice =
|variable_subs_slice: VariableSubsSlice| &variables[variable_subs_slice.indices()];
while let Some(var) = stack.pop() {
// let desc = &mut subs.utable.probe_value_ref_mut(var).value;
let copy = subs.utable.get_copy(var);
if copy.is_none() {
continue;
}
subs.utable.set_rank(var, Rank::NONE);
subs.utable.set_mark(var, Mark::NONE);
subs.utable.set_copy(var, OptVariable::NONE);
use Content::*;
use FlatType::*;
match subs.utable.get_content(var) {
FlexVar(_) | RigidVar(_) | FlexAbleVar(_, _) | RigidAbleVar(_, _) | Error => (),
RecursionVar { structure, .. } => {
stack.push(*structure);
}
Structure(flat_type) => match flat_type {
Apply(_, args) => {
stack.extend(var_slice(*args));
}
Func(arg_vars, closure_var, ret_var) => {
stack.extend(var_slice(*arg_vars));
stack.push(*ret_var);
stack.push(*closure_var);
}
EmptyRecord => (),
EmptyTagUnion => (),
Record(fields, ext_var) => {
stack.extend(var_slice(fields.variables()));
stack.push(*ext_var);
}
TagUnion(tags, ext_var) => {
for slice_index in tags.variables() {
let slice = variable_slices[slice_index.index as usize];
stack.extend(var_slice(slice));
}
stack.push(*ext_var);
}
FunctionOrTagUnion(_, _, ext_var) => {
stack.push(*ext_var);
}
RecursiveTagUnion(rec_var, tags, ext_var) => {
for slice_index in tags.variables() {
let slice = variable_slices[slice_index.index as usize];
stack.extend(var_slice(slice));
}
stack.push(*ext_var);
stack.push(*rec_var);
}
Erroneous(_) => (),
},
Alias(_, args, var, _) => {
stack.extend(var_slice(args.all_variables()));
stack.push(*var);
}
LambdaSet(self::LambdaSet {
solved,
recursion_var,
}) => {
for slice_index in solved.variables() {
let slice = variable_slices[slice_index.index as usize];
stack.extend(var_slice(slice));
}
if let Some(v) = recursion_var.into_variable() {
stack.push(v);
}
}
RangedNumber(typ, _vars) => {
stack.push(*typ);
}
}
}
}
#[derive(Clone, Debug)]
pub struct StorageSubs {
subs: Subs,