aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/infer.rs')
-rw-r--r--crates/ra_hir/src/ty/infer.rs28
1 files changed, 11 insertions, 17 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index f17c6c614..c09260864 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -31,10 +31,10 @@ use ra_prof::profile;
31use test_utils::tested_by; 31use test_utils::tested_by;
32 32
33use super::{ 33use super::{
34 lower, primitive, 34 lower,
35 traits::{Guidance, Obligation, ProjectionPredicate, Solution}, 35 traits::{Guidance, Obligation, ProjectionPredicate, Solution},
36 ApplicationTy, InEnvironment, ProjectionTy, Substs, TraitEnvironment, TraitRef, Ty, TypableDef, 36 ApplicationTy, InEnvironment, ProjectionTy, Substs, TraitEnvironment, TraitRef, Ty, TypableDef,
37 TypeCtor, TypeWalk, 37 TypeCtor, TypeWalk, Uncertain,
38}; 38};
39use crate::{ 39use crate::{
40 adt::VariantDef, 40 adt::VariantDef,
@@ -43,7 +43,7 @@ use crate::{
43 expr::{BindingAnnotation, Body, ExprId, PatId}, 43 expr::{BindingAnnotation, Body, ExprId, PatId},
44 resolve::{Resolver, TypeNs}, 44 resolve::{Resolver, TypeNs},
45 ty::infer::diagnostics::InferenceDiagnostic, 45 ty::infer::diagnostics::InferenceDiagnostic,
46 Adt, AssocItem, ConstData, DefWithBody, FnData, Function, Path, StructField, 46 Adt, AssocItem, ConstData, DefWithBody, FloatTy, FnData, Function, IntTy, Path, StructField,
47}; 47};
48 48
49macro_rules! ty_app { 49macro_rules! ty_app {
@@ -358,14 +358,12 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
358 fn insert_type_vars_shallow(&mut self, ty: Ty) -> Ty { 358 fn insert_type_vars_shallow(&mut self, ty: Ty) -> Ty {
359 match ty { 359 match ty {
360 Ty::Unknown => self.new_type_var(), 360 Ty::Unknown => self.new_type_var(),
361 Ty::Apply(ApplicationTy { 361 Ty::Apply(ApplicationTy { ctor: TypeCtor::Int(Uncertain::Unknown), .. }) => {
362 ctor: TypeCtor::Int(primitive::UncertainIntTy::Unknown), 362 self.new_integer_var()
363 .. 363 }
364 }) => self.new_integer_var(), 364 Ty::Apply(ApplicationTy { ctor: TypeCtor::Float(Uncertain::Unknown), .. }) => {
365 Ty::Apply(ApplicationTy { 365 self.new_float_var()
366 ctor: TypeCtor::Float(primitive::UncertainFloatTy::Unknown), 366 }
367 ..
368 }) => self.new_float_var(),
369 _ => ty, 367 _ => ty,
370 } 368 }
371 } 369 }
@@ -684,12 +682,8 @@ impl InferTy {
684 fn fallback_value(self) -> Ty { 682 fn fallback_value(self) -> Ty {
685 match self { 683 match self {
686 InferTy::TypeVar(..) => Ty::Unknown, 684 InferTy::TypeVar(..) => Ty::Unknown,
687 InferTy::IntVar(..) => { 685 InferTy::IntVar(..) => Ty::simple(TypeCtor::Int(Uncertain::Known(IntTy::i32()))),
688 Ty::simple(TypeCtor::Int(primitive::UncertainIntTy::Known(primitive::IntTy::i32()))) 686 InferTy::FloatVar(..) => Ty::simple(TypeCtor::Float(Uncertain::Known(FloatTy::f64()))),
689 }
690 InferTy::FloatVar(..) => Ty::simple(TypeCtor::Float(
691 primitive::UncertainFloatTy::Known(primitive::FloatTy::f64()),
692 )),
693 InferTy::MaybeNeverTypeVar(..) => Ty::simple(TypeCtor::Never), 687 InferTy::MaybeNeverTypeVar(..) => Ty::simple(TypeCtor::Never),
694 } 688 }
695 } 689 }