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.rs31
1 files changed, 13 insertions, 18 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index f17c6c614..c35378cc4 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,8 @@ 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, HasBody, IntTy, Path,
47 StructField,
47}; 48};
48 49
49macro_rules! ty_app { 50macro_rules! ty_app {
@@ -214,7 +215,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
214 coerce_unsized_map: Self::init_coerce_unsized_map(db, &resolver), 215 coerce_unsized_map: Self::init_coerce_unsized_map(db, &resolver),
215 db, 216 db,
216 owner, 217 owner,
217 body: db.body(owner), 218 body: owner.body(db),
218 resolver, 219 resolver,
219 } 220 }
220 } 221 }
@@ -358,14 +359,12 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
358 fn insert_type_vars_shallow(&mut self, ty: Ty) -> Ty { 359 fn insert_type_vars_shallow(&mut self, ty: Ty) -> Ty {
359 match ty { 360 match ty {
360 Ty::Unknown => self.new_type_var(), 361 Ty::Unknown => self.new_type_var(),
361 Ty::Apply(ApplicationTy { 362 Ty::Apply(ApplicationTy { ctor: TypeCtor::Int(Uncertain::Unknown), .. }) => {
362 ctor: TypeCtor::Int(primitive::UncertainIntTy::Unknown), 363 self.new_integer_var()
363 .. 364 }
364 }) => self.new_integer_var(), 365 Ty::Apply(ApplicationTy { ctor: TypeCtor::Float(Uncertain::Unknown), .. }) => {
365 Ty::Apply(ApplicationTy { 366 self.new_float_var()
366 ctor: TypeCtor::Float(primitive::UncertainFloatTy::Unknown), 367 }
367 ..
368 }) => self.new_float_var(),
369 _ => ty, 368 _ => ty,
370 } 369 }
371 } 370 }
@@ -684,12 +683,8 @@ impl InferTy {
684 fn fallback_value(self) -> Ty { 683 fn fallback_value(self) -> Ty {
685 match self { 684 match self {
686 InferTy::TypeVar(..) => Ty::Unknown, 685 InferTy::TypeVar(..) => Ty::Unknown,
687 InferTy::IntVar(..) => { 686 InferTy::IntVar(..) => Ty::simple(TypeCtor::Int(Uncertain::Known(IntTy::i32()))),
688 Ty::simple(TypeCtor::Int(primitive::UncertainIntTy::Known(primitive::IntTy::i32()))) 687 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), 688 InferTy::MaybeNeverTypeVar(..) => Ty::simple(TypeCtor::Never),
694 } 689 }
695 } 690 }