aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r--crates/hir_ty/src/infer/unify.rs31
1 files changed, 11 insertions, 20 deletions
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs
index 1e9a94c04..b481aa1b3 100644
--- a/crates/hir_ty/src/infer/unify.rs
+++ b/crates/hir_ty/src/infer/unify.rs
@@ -225,36 +225,27 @@ impl InferenceTable {
225 } 225 }
226 } 226 }
227 227
228 fn new_var(&mut self, kind: TyVariableKind, diverging: bool) -> Ty {
229 self.type_variable_table.push(TypeVariableData { diverging });
230 let key = self.var_unification_table.new_key(TypeVarValue::Unknown);
231 assert_eq!(key.0 as usize, self.type_variable_table.inner.len() - 1);
232 Ty::InferenceVar(InferenceVar::from_inner(key), kind)
233 }
234
228 pub(crate) fn new_type_var(&mut self) -> Ty { 235 pub(crate) fn new_type_var(&mut self) -> Ty {
229 self.type_variable_table.push(TypeVariableData { diverging: false }); 236 self.new_var(TyVariableKind::General, false)
230 Ty::InferenceVar(
231 InferenceVar::from_inner(self.var_unification_table.new_key(TypeVarValue::Unknown)),
232 TyVariableKind::General,
233 )
234 } 237 }
235 238
236 pub(crate) fn new_integer_var(&mut self) -> Ty { 239 pub(crate) fn new_integer_var(&mut self) -> Ty {
237 self.type_variable_table.push(TypeVariableData { diverging: false }); 240 self.new_var(TyVariableKind::Integer, false)
238 Ty::InferenceVar(
239 InferenceVar::from_inner(self.var_unification_table.new_key(TypeVarValue::Unknown)),
240 TyVariableKind::Integer,
241 )
242 } 241 }
243 242
244 pub(crate) fn new_float_var(&mut self) -> Ty { 243 pub(crate) fn new_float_var(&mut self) -> Ty {
245 self.type_variable_table.push(TypeVariableData { diverging: false }); 244 self.new_var(TyVariableKind::Float, false)
246 Ty::InferenceVar(
247 InferenceVar::from_inner(self.var_unification_table.new_key(TypeVarValue::Unknown)),
248 TyVariableKind::Float,
249 )
250 } 245 }
251 246
252 pub(crate) fn new_maybe_never_var(&mut self) -> Ty { 247 pub(crate) fn new_maybe_never_var(&mut self) -> Ty {
253 self.type_variable_table.push(TypeVariableData { diverging: true }); 248 self.new_var(TyVariableKind::General, true)
254 Ty::InferenceVar(
255 InferenceVar::from_inner(self.var_unification_table.new_key(TypeVarValue::Unknown)),
256 TyVariableKind::General,
257 )
258 } 249 }
259 250
260 pub(crate) fn resolve_ty_completely(&mut self, ty: Ty) -> Ty { 251 pub(crate) fn resolve_ty_completely(&mut self, ty: Ty) -> Ty {