diff --git a/compiler/can/src/constraint.rs b/compiler/can/src/constraint.rs index 193782daf5..983f4cba21 100644 --- a/compiler/can/src/constraint.rs +++ b/compiler/can/src/constraint.rs @@ -125,7 +125,10 @@ impl Constraints { Type::EmptyRec => EitherIndex::from_left(Self::EMPTY_RECORD), Type::EmptyTagUnion => EitherIndex::from_left(Self::EMPTY_TAG_UNION), Type::Variable(var) => { - let index: Index = Index::push_new(&mut self.variables, var); + // that's right, we use the variable's integer value as the index + // that way, we don't need to push anything onto a vector + let index: Index = Index::new(var.index()); + EitherIndex::from_right(index) } other => { diff --git a/compiler/solve/src/solve.rs b/compiler/solve/src/solve.rs index e0afc00962..37783d98cc 100644 --- a/compiler/solve/src/solve.rs +++ b/compiler/solve/src/solve.rs @@ -890,8 +890,8 @@ fn either_type_index_to_var( type_to_var(subs, rank, pools, _alias_map, typ) } Err(var_index) => { - let var = constraints.variables[var_index.index()]; - var + // we cheat, and store the variable directly in the index + unsafe { Variable::from_index(var_index.index() as _) } } } }