diff options
Diffstat (limited to 'crates/hir_ty/src/infer.rs')
-rw-r--r-- | crates/hir_ty/src/infer.rs | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index a1769729f..1d78d1feb 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs | |||
@@ -36,12 +36,11 @@ use stdx::impl_from; | |||
36 | use syntax::SmolStr; | 36 | use syntax::SmolStr; |
37 | 37 | ||
38 | use super::{ | 38 | use super::{ |
39 | primitive::{FloatTy, IntTy}, | ||
40 | traits::{Guidance, Obligation, ProjectionPredicate, Solution}, | 39 | traits::{Guidance, Obligation, ProjectionPredicate, Solution}, |
41 | InEnvironment, ProjectionTy, Substs, TraitEnvironment, TraitRef, Ty, TypeWalk, | 40 | InEnvironment, ProjectionTy, Substs, TraitEnvironment, TraitRef, Ty, TypeWalk, |
42 | }; | 41 | }; |
43 | use crate::{ | 42 | use crate::{ |
44 | db::HirDatabase, infer::diagnostics::InferenceDiagnostic, lower::ImplTraitLoweringMode, Scalar, | 43 | db::HirDatabase, infer::diagnostics::InferenceDiagnostic, lower::ImplTraitLoweringMode, |
45 | }; | 44 | }; |
46 | 45 | ||
47 | pub(crate) use unify::unify; | 46 | pub(crate) use unify::unify; |
@@ -655,30 +654,17 @@ impl<'a> InferenceContext<'a> { | |||
655 | /// two are used for inference of literal values (e.g. `100` could be one of | 654 | /// two are used for inference of literal values (e.g. `100` could be one of |
656 | /// several integer types). | 655 | /// several integer types). |
657 | #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] | 656 | #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] |
658 | pub enum InferTy { | 657 | pub struct InferenceVar { |
659 | TypeVar(unify::TypeVarId), | 658 | index: u32, |
660 | IntVar(unify::TypeVarId), | ||
661 | FloatVar(unify::TypeVarId), | ||
662 | MaybeNeverTypeVar(unify::TypeVarId), | ||
663 | } | 659 | } |
664 | 660 | ||
665 | impl InferTy { | 661 | impl InferenceVar { |
666 | fn to_inner(self) -> unify::TypeVarId { | 662 | fn to_inner(self) -> unify::TypeVarId { |
667 | match self { | 663 | unify::TypeVarId(self.index) |
668 | InferTy::TypeVar(ty) | ||
669 | | InferTy::IntVar(ty) | ||
670 | | InferTy::FloatVar(ty) | ||
671 | | InferTy::MaybeNeverTypeVar(ty) => ty, | ||
672 | } | ||
673 | } | 664 | } |
674 | 665 | ||
675 | fn fallback_value(self) -> Ty { | 666 | fn from_inner(unify::TypeVarId(index): unify::TypeVarId) -> Self { |
676 | match self { | 667 | InferenceVar { index } |
677 | InferTy::TypeVar(..) => Ty::Unknown, | ||
678 | InferTy::IntVar(..) => Ty::Scalar(Scalar::Int(IntTy::I32)), | ||
679 | InferTy::FloatVar(..) => Ty::Scalar(Scalar::Float(FloatTy::F64)), | ||
680 | InferTy::MaybeNeverTypeVar(..) => Ty::Never, | ||
681 | } | ||
682 | } | 668 | } |
683 | } | 669 | } |
684 | 670 | ||