diff options
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/infer/unify.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index d8edfb4e9..259feecf1 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs | |||
@@ -149,7 +149,9 @@ impl TypeVariableTable { | |||
149 | 149 | ||
150 | fn fallback_value(&self, iv: InferenceVar, kind: TyVariableKind) -> Ty { | 150 | fn fallback_value(&self, iv: InferenceVar, kind: TyVariableKind) -> Ty { |
151 | match kind { | 151 | match kind { |
152 | _ if self.inner[iv.index() as usize].diverging => TyKind::Never, | 152 | _ if self.inner.get(iv.index() as usize).map_or(false, |data| data.diverging) => { |
153 | TyKind::Never | ||
154 | } | ||
153 | TyVariableKind::General => TyKind::Error, | 155 | TyVariableKind::General => TyKind::Error, |
154 | TyVariableKind::Integer => TyKind::Scalar(Scalar::Int(IntTy::I32)), | 156 | TyVariableKind::Integer => TyKind::Scalar(Scalar::Int(IntTy::I32)), |
155 | TyVariableKind::Float => TyKind::Scalar(Scalar::Float(FloatTy::F64)), | 157 | TyVariableKind::Float => TyKind::Scalar(Scalar::Float(FloatTy::F64)), |
@@ -205,6 +207,7 @@ impl<'a> InferenceTable<'a> { | |||
205 | fn new_var(&mut self, kind: TyVariableKind, diverging: bool) -> Ty { | 207 | fn new_var(&mut self, kind: TyVariableKind, diverging: bool) -> Ty { |
206 | let var = self.var_unification_table.new_variable(UniverseIndex::ROOT); | 208 | let var = self.var_unification_table.new_variable(UniverseIndex::ROOT); |
207 | // Chalk might have created some type variables for its own purposes that we don't know about... | 209 | // Chalk might have created some type variables for its own purposes that we don't know about... |
210 | // TODO refactor this? | ||
208 | self.type_variable_table.inner.extend( | 211 | self.type_variable_table.inner.extend( |
209 | (0..1 + var.index() as usize - self.type_variable_table.inner.len()) | 212 | (0..1 + var.index() as usize - self.type_variable_table.inner.len()) |
210 | .map(|_| TypeVariableData { diverging: false }), | 213 | .map(|_| TypeVariableData { diverging: false }), |