aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorLenard Pratt <[email protected]>2019-04-04 23:29:21 +0100
committerLenard Pratt <[email protected]>2019-04-07 13:23:14 +0100
commite175921932615cb97eaa5cfd11d940cbd1473cac (patch)
tree14830570c216a7536848b652ded69fdea48ad9c7 /crates/ra_hir/src/ty
parent2d73c909fe03c799b488aa0f97a588e13bbd7006 (diff)
Added ArrayExprKind,
changed the display for fixed array types, Added Array Enum to ra_hir/expr
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/infer.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index d8f4ce9f8..9ace6b13a 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -32,7 +32,7 @@ use crate::{
32 DefWithBody, 32 DefWithBody,
33 ImplItem, 33 ImplItem,
34 type_ref::{TypeRef, Mutability}, 34 type_ref::{TypeRef, Mutability},
35 expr::{Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement, FieldPat, self}, 35 expr::{Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement, FieldPat,Array, self},
36 generics::GenericParams, 36 generics::GenericParams,
37 path::{GenericArgs, GenericArg}, 37 path::{GenericArgs, GenericArg},
38 adt::VariantDef, 38 adt::VariantDef,
@@ -1074,7 +1074,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1074 1074
1075 Ty::apply(TypeCtor::Tuple, Substs(ty_vec.into())) 1075 Ty::apply(TypeCtor::Tuple, Substs(ty_vec.into()))
1076 } 1076 }
1077 Expr::Array { exprs, repeat } => { 1077 Expr::Array(array) => {
1078 let elem_ty = match &expected.ty { 1078 let elem_ty = match &expected.ty {
1079 Ty::Apply(a_ty) => match a_ty.ctor { 1079 Ty::Apply(a_ty) => match a_ty.ctor {
1080 TypeCtor::Slice | TypeCtor::Array => { 1080 TypeCtor::Slice | TypeCtor::Array => {
@@ -1085,17 +1085,21 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1085 _ => self.new_type_var(), 1085 _ => self.new_type_var(),
1086 }; 1086 };
1087 1087
1088 for expr in exprs.iter() { 1088 match array {
1089 self.infer_expr(*expr, &Expectation::has_type(elem_ty.clone())); 1089 Array::ElementList(items) => {
1090 } 1090 for expr in items.iter() {
1091 1091 self.infer_expr(*expr, &Expectation::has_type(elem_ty.clone()));
1092 if let Some(expr) = repeat { 1092 }
1093 self.infer_expr( 1093 }
1094 *expr, 1094 Array::Repeat { initializer, repeat } => {
1095 &Expectation::has_type(Ty::simple(TypeCtor::Int( 1095 self.infer_expr(*initializer, &Expectation::has_type(elem_ty.clone()));
1096 primitive::UncertainIntTy::Known(primitive::IntTy::usize()), 1096 self.infer_expr(
1097 ))), 1097 *repeat,
1098 ); 1098 &Expectation::has_type(Ty::simple(TypeCtor::Int(
1099 primitive::UncertainIntTy::Known(primitive::IntTy::usize()),
1100 ))),
1101 );
1102 }
1099 } 1103 }
1100 1104
1101 Ty::apply_one(TypeCtor::Array, elem_ty) 1105 Ty::apply_one(TypeCtor::Array, elem_ty)