From 5183c9f08345c664237ae138e86f96ff46714f15 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 28 Feb 2021 01:20:04 +0100 Subject: Introduce TypeCtor::Scalar --- crates/hir_ty/src/infer/unify.rs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'crates/hir_ty/src/infer/unify.rs') diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 76984242e..57eb8cede 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs @@ -8,8 +8,8 @@ use test_utils::mark; use super::{InferenceContext, Obligation}; use crate::{ - BoundVar, Canonical, DebruijnIndex, GenericPredicate, InEnvironment, InferTy, Substs, Ty, - TyKind, TypeCtor, TypeWalk, + BoundVar, Canonical, DebruijnIndex, GenericPredicate, InEnvironment, InferTy, Scalar, Substs, + Ty, TyKind, TypeCtor, TypeWalk, }; impl<'a> InferenceContext<'a> { @@ -300,10 +300,24 @@ impl InferenceTable { | (other, Ty::Infer(InferTy::TypeVar(tv))) | (Ty::Infer(InferTy::MaybeNeverTypeVar(tv)), other) | (other, Ty::Infer(InferTy::MaybeNeverTypeVar(tv))) - | (Ty::Infer(InferTy::IntVar(tv)), other @ ty_app!(TypeCtor::Int(_))) - | (other @ ty_app!(TypeCtor::Int(_)), Ty::Infer(InferTy::IntVar(tv))) - | (Ty::Infer(InferTy::FloatVar(tv)), other @ ty_app!(TypeCtor::Float(_))) - | (other @ ty_app!(TypeCtor::Float(_)), Ty::Infer(InferTy::FloatVar(tv))) => { + | (Ty::Infer(InferTy::IntVar(tv)), other @ ty_app!(TypeCtor::Scalar(Scalar::Int(_)))) + | (other @ ty_app!(TypeCtor::Scalar(Scalar::Int(_))), Ty::Infer(InferTy::IntVar(tv))) + | ( + Ty::Infer(InferTy::IntVar(tv)), + other @ ty_app!(TypeCtor::Scalar(Scalar::Uint(_))), + ) + | ( + other @ ty_app!(TypeCtor::Scalar(Scalar::Uint(_))), + Ty::Infer(InferTy::IntVar(tv)), + ) + | ( + Ty::Infer(InferTy::FloatVar(tv)), + other @ ty_app!(TypeCtor::Scalar(Scalar::Float(_))), + ) + | ( + other @ ty_app!(TypeCtor::Scalar(Scalar::Float(_))), + Ty::Infer(InferTy::FloatVar(tv)), + ) => { // the type var is unknown since we tried to resolve it self.var_unification_table.union_value(*tv, TypeVarValue::Known(other.clone())); true -- cgit v1.2.3