diff --git a/compiler/solve/src/solve.rs b/compiler/solve/src/solve.rs index 295ce253d3..0fbb9cf689 100644 --- a/compiler/solve/src/solve.rs +++ b/compiler/solve/src/solve.rs @@ -3028,13 +3028,7 @@ fn deep_copy_var_in( // we have tracked all visited variables, and can now traverse them // in one go (without looking at the UnificationTable) and clear the copy field for var in visited { - subs.modify(var, |descriptor| { - if descriptor.copy.is_some() { - descriptor.rank = Rank::NONE; - descriptor.mark = Mark::NONE; - descriptor.copy = OptVariable::NONE; - } - }); + subs.set_copy_unchecked(var, OptVariable::NONE); } copy @@ -3198,7 +3192,7 @@ fn deep_copy_var_help( } }; - subs.set(copy, make_descriptor(Structure(new_flat_type))); + subs.set_content_unchecked(copy, Structure(new_flat_type)); copy } @@ -3211,25 +3205,24 @@ fn deep_copy_var_help( } => { let new_structure = deep_copy_var_help(subs, max_rank, pools, visited, structure); - subs.set( - copy, - make_descriptor(RecursionVar { - opt_name, - structure: new_structure, - }), - ); + let content = RecursionVar { + opt_name, + structure: new_structure, + }; + + subs.set_content_unchecked(copy, content); copy } RigidVar(name) => { - subs.set(copy, make_descriptor(FlexVar(Some(name)))); + subs.set_content_unchecked(copy, FlexVar(Some(name))); copy } RigidAbleVar(name, ability) => { - subs.set(copy, make_descriptor(FlexAbleVar(Some(name), ability))); + subs.set_content_unchecked(copy, FlexAbleVar(Some(name), ability)); copy } @@ -3247,7 +3240,7 @@ fn deep_copy_var_help( deep_copy_var_help(subs, max_rank, pools, visited, real_type_var); let new_content = Alias(symbol, new_arguments, new_real_type_var, kind); - subs.set(copy, make_descriptor(new_content)); + subs.set_content_unchecked(copy, new_content); copy } @@ -3259,7 +3252,7 @@ fn deep_copy_var_help( let new_content = RangedNumber(new_type_var, new_variables); - subs.set(copy, make_descriptor(new_content)); + subs.set_content_unchecked(copy, new_content); copy } diff --git a/compiler/types/src/subs.rs b/compiler/types/src/subs.rs index a65e8c8846..da17f69d44 100644 --- a/compiler/types/src/subs.rs +++ b/compiler/types/src/subs.rs @@ -1720,11 +1720,13 @@ impl Subs { } pub fn set_content(&mut self, key: Variable, content: Content) { - // let l_key = self.utable.inlined_get_root_key(key); - self.utable.set_content(key, content); } + pub fn set_content_unchecked(&mut self, key: Variable, content: Content) { + self.utable.set_content_unchecked(key, content); + } + pub fn modify(&mut self, key: Variable, mapper: F) -> T where F: FnOnce(&mut Descriptor) -> T,